smoothing a curve efficiently

조회 수: 87 (최근 30일)
raha ahmadi
raha ahmadi 2021년 5월 10일
편집: raha ahmadi 2021년 5월 11일
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