MATLAB Answers

Jason
0

filling in between two curves with different x values

Asked by Jason
on 12 Mar 2018
Latest activity Commented on by Star Strider
on 12 Mar 2018
Hello.
I have a plot
plot(x,y,'r--','LineWidth', 2);
that I want to display with boundaries such that:
plot(x+5,y,'k--','LineWidth', 0.5);
plot(x-5,y,'k--','LineWidth', 0.5);
I want to shade the area in between and have tried:
patch([k-5 k+5], [y y], 'g')
but I can't get it to work.
Thanks for any help.

  0 Comments

Sign in to comment.

Tags

1 Answer

Answer by Guillaume
on 12 Mar 2018
 Accepted Answer

I would think that
patch([x-5, fliplr(x+5)], [y fliplr(y)], 'g')
should work.

  8 Comments

Not necessary to ‘force’ anything. You can imply L’Hospital’s Rule and avoid NaN values this way:
y = abs(sin(X+1E-8)./(X+1E-8));
Thankyou for reminding me about Mr Hosptial!
Jason
We’re all in this together!

Sign in to comment.