
Smoothing of an error curve
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
nth24601
am 1 Apr. 2020
Kommentiert: nth24601
am 1 Apr. 2020
Hello guys
I am working on my dissertation and I have a few graphs that I need to smooth out. Those are error graphs so they cannot go below 0. I used to use excel to smooth them out giving the following graph:

But now I must recreate the graph in MATLAB to stay consistent throughout the document. I have tried the smooth(x,y) function but it does not smooth the graph out at all, it just messes it up. I have tried the curve fitting tool as well as csaps and interp1 spline fitting functions but they cause the values to go below 0, which I cannot have as I will be using a log scale to plot the graph. The data from the above graph looks as follows:
A1=[0.31077 0.53279 0.021153 0.011143 0.001778 0.000642];
B1=[780 1560 3924 7344 11820 17352];
A2=[0.076948 0.119 0.009376 0.000887 4.27*10^(-5) 7.56*10^(-6)];
B2=[2368 4736 11928 22336 35960 52800];
A3=[0.039363 0.040862 0.002222 6.42*10^(-5) 1.73*10^(-6) 3.10*10^(-8)];
B3=[10059 20118 50391 94140 151365 222066];
With A vectors being the Error values and B vectors being the NDOF values for each curve. I have tried the following code using the interp1 function:
xq=B1(1,1):100:B1(1,6);
vq=interp1(B1,A1,xq,'spline');
plot(xq,vq);
hold on
xq=B2(1,1):100:B2(1,6);
vq=interp1(B2,A2,xq,'spline');
plot(xq,vq)
hold on
xq=B3(1,1):100:B3(1,6);
vq=interp1(B3,A3,xq,'spline');
plot(xq,vq)
set(gca,'XScale','log');
set(gca,'YScale','log');
But as I said, the spline fitting method causes the values to go into negative, and then they get ignored by the plot because of the log scale. I have tried cubic methods but the graphs really do not look right with them, and when I tried the cftool most graphs there did not converge to the final value of the graphs from excel, which is important as I am trying to show error convergence.
Does anyone know any technique that can recreate these graphs in a smooth way using this data ? I have researched the excel algorithm used for smoothing the graphs and it is apparently called a Bezier spline, but I do not know how to apply it for curve fitting in matlab. The only thing I managed to find is a mention of a bspline function, but it seems to only plot the spline for some non-decreasing value array, rather than use it to smooth out curves.
0 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 1 Apr. 2020
Bearbeitet: Ameer Hamza
am 1 Apr. 2020
Use 'pchip' interpolation
A1=[0.31077 0.53279 0.021153 0.011143 0.001778 0.000642];
B1=[780 1560 3924 7344 11820 17352];
A2=[0.076948 0.119 0.009376 0.000887 4.27*10^(-5) 7.56*10^(-6)];
B2=[2368 4736 11928 22336 35960 52800];
A3=[0.039363 0.040862 0.002222 6.42*10^(-5) 1.73*10^(-6) 3.10*10^(-8)];
B3=[10059 20118 50391 94140 151365 222066];
xq=B1(1,1):100:B1(1,6);
vq=interp1(B1,A1,xq,'pchip');
loglog(xq,vq,'-', B1,A1,'+');
hold on
xq=B2(1,1):100:B2(1,6);
vq=interp1(B2,A2,xq,'pchip');
loglog(xq,vq,'-', B2,A2,'+');
hold on
xq=B3(1,1):100:B3(1,6);
vq=interp1(B3,A3,xq,'pchip');
loglog(xq,vq,'-', B3,A3,'+');

Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!