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 个评论

hello
maybe it work be worth to share the code and data so we can better help you
tx
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
hello
can you share the raw data as well ?
tx

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 2-D and 3-D Plots 的更多信息

提问:

2021-5-14

Community Treasure Hunt

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

Start Hunting!

Translated by