Reputation: 13
I want to draw a line in matlab. My scenario is like x=[-400:400] and 'y' should be of the same length but an irregular slope continuous line and finally I want to use plot command for plotting, say plot(x,y). Can anybody suggest how to do it.
Thanks
Upvotes: 0
Views: 470
Reputation: 8468
Assume you want to plot in steps of 1, then you have:
x1=-400:-300;
x2=-300:-200;
x3=-200:300;
x=[x1 x2 x3];
And then for y you will have:
y1=ones(1,length(x1));
y2=(-200-150)/(-200+300) (x2+300) + 150;
y3=(200+200)/(300+200) (x3+200) - 200;
y=[y1 y2 y3]
And then :
plot(x,y)
Upvotes: 1