Plotting of graph showing increasing & decreasing in the same plot

4 次查看(过去 30 天)
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

采纳的回答

Walter Roberson
Walter Roberson 2017-9-28
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by