Plotting of graph showing increasing & decreasing in the same plot
조회 수: 9 (최근 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
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!