MATLAB: How to draw progressive in matlab

matlab progressive plot

Hi, I want in a representation of a function to cut in some point and increase the value of y at least 100 points, but i want to be progressive in a short place in x, not just in one point increase from 10 to 110.
How can I do it?

Best Answer

f = @(x) x.^3 - 5 .* x - 5;
bound1 = 3; bound2 = 4.5; increase = 100;
x = linspace(-2, 6);
y = zeros(size(x));
mask = x <= bound1;
y(mask) = f( x(mask) );
mask = x > bound1 & x <= bound2;
y(mask) = f( x(mask) ) + (x(mask)-bound1) .* increase ./ (bound2 - bound1);
mask = x > bound2;
y(mask) = f( x(mask) ) + increase;
plot(x, y)
Related Question