Limit SmoothingSpline plot to smoothdata plot

Hello,
i have data, which i plot, then smoothe with dx = smoothdata(x, 'movmedian'). Now I would like to insert a smoothspline with fit into my plot. Unfortunately the smoothingspline does not start where my first data point of my smoothdata is, but earlier. How can I plot a specific section of a smoothingspline. Thanks for the help.

3 件のコメント

Mathieu NOE
Mathieu NOE 2021 年 5 月 15 日
hello
maybe it work be worth to share the code and data so we can better help you
tx
TB_011
TB_011 2021 年 5 月 17 日
ft = fittype('smoothingspline');
opts = fitoptions('Method', 'SmoothingSpline', 'SmoothingParam', 0.04);
plot(t, x_min, 'g')
hold on
plot(t, x_max, 'g')
sdx_max = smoothdata(x_max, 'movmedian', 25);
sdx_min = smoothdata(x_min, 'movmedian', 25);
plot(t, sdx_max, 'c-', 'LineWidth',1.5);
plot(t, sdx_min, 'c-', 'LineWidth',1.5);
f = fit(t', sdx_min, ft, opts);
f_lim = plot(f);
set(f_lim, 'Color', 'r', 'LineWidth', 1);
g = fit(t', sdx_max, ft, opts);
g_lim = plot(g);
set(g_lim, 'Color', 'b', 'LineWidth', 1);
hold off
grid('on')
yticks([-1.5:0.5:2.5])
xticks([-15:5:25])
ylabel('x-distance [m]')
xlabel('time [s]')
xlim([-15 25]);
ylim([-1.5 2.5]);
legend('off')
This is my code.
The green plots are my rawdata, the light blue ones my smoothed plot. The red and blue lines are my fitted plots with the fitoption and type 'smoothingspline'
As you can see, my SmoothingSpline doesn't have the same startingpoint as my smoothed data line. In this case my time t_0 (x axis) is -7.60. I would like to start plotting my smoothing spline from my t_0, but nothing worked.
Thank you for your help
Mathieu NOE
Mathieu NOE 2021 年 5 月 17 日
hello
can you share the raw data as well ?
tx

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

回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

質問済み:

2021 年 5 月 14 日

コメント済み:

2021 年 5 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by