Want to combine two plots

조회 수: 2 (최근 30일)
Anshuman S
Anshuman S 2019년 7월 2일
답변: Star Strider 2019년 7월 2일
I want to plot y1 = 100.0 - 90.0*exp(-0.0465*t); and y2 = 203.6 - 11.3*t; together on the same plot
and then plot ( y = y1 +y2 ) for t = (0,50) but I don't want to include the (-ve) values of y2, i.e replace the (-ve) values of y2 with zero.
something like a new function y3 = [ ( if (t<203.6/11.3) y3 = y2 else y3 = 0 ]

채택된 답변

Star Strider
Star Strider 2019년 7월 2일
Try this:
t = linspace(0, 50);
y1 = 100.0 - 90.0*exp(-0.0465*t);
y2 = 203.6 - 11.3*t;
y2 = y2 .* (y2 >= 0); % Set Negative ‘y2’ To Zero
y = y1 + y2;
figure
plot(t, y)
grid
xlabel('t')
ylabel('y')
That should do what you want.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by