How to plot x and y

조회 수: 1 (최근 30일)
Hung Luu
Hung Luu 2021년 10월 10일
편집: Dave B 2021년 10월 10일
I want to plot x and y like:x=3t and y=2t with t=0->100. How can I do that ?

답변 (2개)

Dave B
Dave B 2021년 10월 10일
편집: Dave B 2021년 10월 10일
There are a couple of options for how you think about this problem. I might do it like this:
t = 0:100; % you could just do [0 100] because everything is linear...
plot(3*t,2*t)
But an alternative is to use the fplot function which takes in functions directly (rather than functions applied discretely to a set of points):
figure
fplot(@(t)(3*t),@(t)(2*t),[0 100])
More info can be found at the documentation pages for plot and fplot:

David Hill
David Hill 2021년 10월 10일
t=0:.1:100;
x=3*t;
y=2t;
plot(x,y);

카테고리

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