Curve on specific X and Y coordinates

2 ビュー (過去 30 日間)
simon beaudet
simon beaudet 2021 年 3 月 19 日
回答済み: Walter Roberson 2021 年 3 月 19 日
i would like to graph a curve that passes through the X, Y coordinates
x = [429.245/3, 303.996/3, 287.771/3, 267.384/3, 252.095/3, 239.755/3, 224.149/3, 201.129/3, 0, -198.87/3, 222.745/3, 237.498/3, 249.837/3, 265.127/3, 285.513/3, 301.739/3, 432.098/3];
y = [ 20.61/3, 20.61/3, 20.61/3, 16.436/3, 10.8/3, 6.243/3, 2.488/3, 0, 0, 0, 2.488/3, 6.243/3, 10.8/3, 16.436/3, 20.61/3, 20.61/3, 20.61/3];

回答 (2 件)

John D'Errico
John D'Errico 2021 年 3 月 19 日
編集済み: John D'Errico 2021 年 3 月 19 日
x = [429.245/3, 303.996/3, 287.771/3, 267.384/3, 252.095/3,239.755/3,224.149/3,201.129/3,0,-198.87/3, 222.745/3,237.498/3,249.837/3,265.127/3,285.513/3,301.739/3,432.098/3];
y = [20.61/3, 20.61/3, 20.61/3, 16.436/3, 10.8/3,6.243/3, 2.488/3,0,0,0,2.488/3,6.243/3,10.8/3,16.436/3,20.61/3,20.61/3,20.61/3];
plot(x,y,'-')
Done. Did you really expect some nice smooth well-behaved curve? I hope not. Is there some information you know about the curve? If there is, then how do you expect a computer to know what you know?

Walter Roberson
Walter Roberson 2021 年 3 月 19 日
Difficult to say what you want in a curve when it doubles back on itself.
If this is intended as a hysterisis curve then you should say so instead of just giving it as a list of points.
x = [429.245/3, 303.996/3, 287.771/3, 267.384/3, 252.095/3, 239.755/3, 224.149/3, 201.129/3, 0, -198.87/3, 222.745/3, 237.498/3, 249.837/3, 265.127/3, 285.513/3, 301.739/3, 432.098/3];
y = [ 20.61/3, 20.61/3, 20.61/3, 16.436/3, 10.8/3, 6.243/3, 2.488/3, 0, 0, 0, 2.488/3, 6.243/3, 10.8/3, 16.436/3, 20.61/3, 20.61/3, 20.61/3];
[sx, idx] = sort(x);
sy = y(idx);
plot(x, y, '-*k'); ylim([-1 8])
plot(sx, sy, '--+b'); ylim([-1 8])
ix = linspace(sx(1),sx(end));
iy = interp1(sx, sy, ix, 'spline');
plot(sx, sy, '--+b', ix, iy, '-.sg'); ylim([-3 8])

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by