curve line like Excel

please how i can get like the excel curve
x = [-0.001997568 0.002377296 0.002564918 -0.0021569 -0.001997568]
y = [-0.001082305 -0.007057942 0.002240446 0.008950567 -0.001082305]

4 件のコメント

dpb
dpb 2018 年 8 月 12 日
Matlab is sorely lacking in such enhancements...it would require building an interpolating functional manually; I don't know there's anything prepackaged to do such.
Touts Touts
Touts Touts 2018 年 8 月 12 日
I have found this code, but its does not work for me ?
%%plot 1
figure
x = [1 2 3 1.5];
y = [1 4 9 5];
scatter(x,y)
hold on
line(x,y)
xlim([0 4])
ylim([0 10])
%%plot 2
figure
sorted=sortrows([x' y']);
sorted_x = sorted(:,1);
sorted_y = sorted(:,2);
scatter(sorted_x,sorted_y)
hold on
line(sorted_x,sorted_y)
xlim([0 4])
ylim([0 10])
%%plot 3
figure
fitx=linspace(0,4,100);
fity = interp1(sorted_x,sorted_y,fitx,'spline');
scatter(sorted_x,sorted_y)
hold on
line(fitx,fity)
xlim([0 4])
ylim([0 10])
dpb
dpb 2018 年 8 月 12 日
Don't know what you expected but it does what it was written to do...draws a line with some unordered points, rearranges the points in x-ascending order and plots, then smooths the graph with a spline.
Looks like it was just intended as a simple demonstration; wasn't purporting to solve any great problem.
It would take building a smoothing bounding surface in 2D through the polygon points to build a line such as that in the example posted; as noted, afaik there's not a trivial function prepackaged in ML to do such.
You might try to search on FileExchange and see if somebody has done something similar...

サインインしてコメントする。

回答 (0 件)

製品

リリース

R2009b

質問済み:

2018 年 8 月 12 日

コメント済み:

2019 年 7 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by