smoothing a curve efficiently

137 次查看(过去 30 天)
Hi , I need to make my curve smooth and I use all of the method simoltaneouly but my data need to be more smooth. how can I make this happen ?
very thanks in advance

采纳的回答

DGM
DGM 2021-5-11
Since you haven't said what you actually attempted and haven't given any sample data or even revealed the domain and range of the plot image, I can only offer a simple example.
% make up some function with a similar appearance
x = linspace(0,10,100);
y = -0.01*(x-6).^2 + 0.05*abs(sin(4*x));
% smooth the thing with an averaging filter
ys = smooth(y,20);
% smooth the thing with a spline fit (uses CFT)
fm = fit(x',y','smoothingspline','smoothingparam',0.9);
plot(x,y,'k:'); hold on; grid on
plot(x,ys,'r')
plot(x,fm(x),'b')
legend('original','average','spline','location','southeast')
You'd obviously have to tailor the parameters to whatever data you're actually using.
  1 个评论
raha ahmadi
raha ahmadi 2021-5-11
Dear DGM;
I really appericiate your help and time. It works
I wish the best for you

请先登录,再进行评论。

更多回答(1 个)

Das Siddharth
Das Siddharth 2021-5-10
Did you try the smooth (MAF) function from the MATLAB ? Try that with smoothing a specific coloumn or row and see what gives you the best result. Hope it helps.
  3 个评论
Das Siddharth
Das Siddharth 2021-5-11
Can you give a sample of your data so that I can try ?
raha ahmadi
raha ahmadi 2021-5-11
编辑:raha ahmadi 2021-5-11
Dear Siddharth
Thank you for your attention. This is a small part of my data. I need a realy smooth gradient but as you see although the graph seems smooth but the gradient has sharp changes
Best wishes
clc
clear
close all
T=[304.998454103946;304.997649607535;305.004722282365;305.01001273423;...
305.013520963129;305.015246969062;305.015190752029;305.013352312031;...
305.01902116925;305.022835253892;305.024794565955];
x=[3848.22104674965;3849.36319865994;3850.50535057022;3851.64750248051;...
3852.78965439079;3853.93180630108;3855.07395821137;3856.21611012166;...
3857.35826203194;3858.50041394223;3859.64256585251];
T1=smooth(T,'moving');
T2=smooth(T1,'lowess');
T3=smooth(T2,'loess');
T4=smooth(T3,'sgolay');
T5=smooth(T4,'rlowess');
T6=smooth(T5,'rloess');
plot(x,T,'k:');
hold on
plot(x,T6,'k')
legend('original','to be smooth')
ylabel('T')
dTdy=gradient(T);
figure
plot(x,dTdy,'k:')
hold on
dT6dy=gradient(T6);
ylabel('dTdx')
plot(x,dT6dy,'k')
legend('original', 'to be smooth')

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Multirate Signal Processing 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by