Interpolating near discontinuties

Hello Everyone,
I have a very itchy problem.
I am trying to plot the following function which has jump discontinuities.
x=0:0.0001:2;
y=5*x;
x1=2:0.0001:3;
y1=5*(x1)+1;
plot(x,y,x1,y1);
This is giving a plot which has a jump discontinuity at 2. I want the matlab to join discontinuity by a line.
Thanks in advance.
Thanks & Regards,
Arun Sahu

 Accepted Answer

f = @(x)5*x + (x > 2)
plot(0:1e-4:3,f(0:1e-4:3))
OR:
x=0:0.0001:2;
y=5*x;
x1=2:0.0001:3;
y1=5*(x1)+1;
plot([x,x1],[y,y1]);

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!