smoothing a curve efficiently

69 visualizaciones (últimos 30 días)
raha ahmadi
raha ahmadi el 10 de Mayo de 2021
Editada: raha ahmadi el 11 de Mayo de 2021
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

Respuesta aceptada

DGM
DGM el 11 de Mayo de 2021
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 comentario
raha ahmadi
raha ahmadi el 11 de Mayo de 2021
Dear DGM;
I really appericiate your help and time. It works
I wish the best for you

Iniciar sesión para comentar.

Más respuestas (1)

Das Siddharth
Das Siddharth el 10 de Mayo de 2021
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 comentarios
Das Siddharth
Das Siddharth el 11 de Mayo de 2021
Can you give a sample of your data so that I can try ?
raha ahmadi
raha ahmadi el 11 de Mayo de 2021
Editada: raha ahmadi el 11 de Mayo de 2021
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')

Iniciar sesión para comentar.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by