Creating a line with "line" and obtaining the points.

1 回表示 (過去 30 日間)
Silvia
Silvia 2011 年 6 月 22 日
Hello,
I have created a line between two points using "line" but I need to obtain the points which form that line. Is there any way to do that?? Thank you Silvia

回答 (3 件)

Gerd
Gerd 2011 年 6 月 22 日
Hi Silvia,
first of all I would create a new vector out of your two "x" values(depending on your needs/resolution). Then using, what Arturo already said, the interp1 function to get the new values.
x1=0
y0=0
x2=10;
y2=10;
invector=linspace(x1,x2,1000);
erg=interp1([x1 x2],[y1 y2], invector);
plot(invector,erg)
Now you have the interpolated values of your line.
Gerd

Jan
Jan 2011 年 6 月 22 日
There is no need to call the slow INTERP1:
x1 = 0;
y0 = 0;
x2 = 10;
y2 = 10;
x = linspace(x1, x2, 1000);
y = linspace(y1, y2, 1000);

Silvia
Silvia 2011 年 6 月 22 日
Thank you very much

カテゴリ

Help Center および File ExchangeNewton-Raphson Method についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by