Plotting of graph showing increasing & decreasing in the same plot

2 views (last 30 days)
I want to plot a graph which should display increasing shape, decreasing shape, etc in one graph without any of the curves affecting each other. How do I modify my code to get this result.
Code:
clear all
x = linspace(0,10);
for i1 = 1:3
q = input('input the shape parameter theta q');
b = input('input the scale parameter beta b');
f = zeros(1,3);
for ii = 1:length(x)
f(ii) = b*q^2*(1+b*x(ii))/(1+b+b*q*x(ii));
end
plot(x,f,'linewidth',2)
hold on
end
legend('\theta=0.5,\beta=0.2','\theta=1.0,\beta=0.2','\theta=1.5,\beta=0.2')
hold off

Accepted Answer

Walter Roberson
Walter Roberson on 28 Sep 2017
To avoid having any of the plots affect the others, you will need to add a line color specification to the plot() command. With the way you have it now, in all versions from R2014b onwards, the "hold on" would trigger automatic use of the "next" color in the ColorOrder property of the axes, so the fact that you made a plot would affect the color given to another plot, contrary to your instructions.

More Answers (0)

Categories

Find more on Line 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!