Help. Plot graph calculation

조회 수: 4 (최근 30일)
Aylin Sogut
Aylin Sogut 2021년 10월 24일
답변: Star Strider 2021년 10월 24일
Hello, I really need help, I need calculate this graph on matlab and I really dont know how, please help me someone

답변 (2개)

Matt J
Matt J 2021년 10월 24일
You mean, how to plot the triangle? You can do,
x=linspace(0,3,1000);
y=(1-abs(x-1));
y=y.*(y>=0);
plot(x,y)

Star Strider
Star Strider 2021년 10월 24일
A somewhat more analytic representation —
x = linspace(-1, 3, 250);
y = (x).*((x >= 0) & (x < 1)) + (2-x).*((x >= 1) & (x < 2));
figure
plot(x, y)
grid
ylim([0 2])
This can then be separated into its component parts, if necessary —
y1 = (x).*((x >= 0) & (x < 1));
y2 = (2-x).*((x >= 1) & (x < 2));
.

카테고리

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