Azzera filtri
Azzera filtri

How do I use Curve Fitting to fit a smooth curve to semilogy data?

18 visualizzazioni (ultimi 30 giorni)
I have a dataset, shown in the figure, to which I would like to plot a smooth curve like in Excel. I tried using a smoothing spline but that doesn't hold up when I plot the data on a log-y axis. Is there a fit that would better suit my needs?
  1 Commento
Erialett Fernandez
Erialett Fernandez il 5 Mar 2020
Modificato: Erialett Fernandez il 5 Mar 2020
I'm having the same issue. I would like to smooth my plot that's on a log scale using semilogx. I have tried both smoothingspline and interpl and neither hold. Please provide examples of code using semilogx because the examples from matlab are using linear aplots nd those don't transfer :)
My normal plot:
f1 = figure;
w = [10^2,10^3,10^4,10^5,10^6];
Vc2 = [5,5,4.45,1.055,0.114];
semilogx(w,Vc2);
xlabel('\omega','FontSize',20,'FonWhentWeight','bold')
ylabel('|V_C(t)|','FontWeight','bold')
title('Part 2 Capacitor')
My attempt at interpl:
f1 = figure;
w = [10^2,10^3,10^4,10^5,10^6];
Vc2 = [5,5,4.45,1.055,0.114];
%Smooth the curve:
wi = logspace(2,6,150);
vi = interp1(w, Vc2, wi, 'spline');
semilogx(w,Vc2,'o',wi,vi);
xlabel('\omega','FontSize',20,'FonWhentWeight','bold')
ylabel('|V_C(t)|','FontWeight','bold')
title('Part 2 Capacitor')
it's somewhat doing it but I would like something much closer to the original shape of my first plot.

Accedi per commentare.

Risposte (1)

Ankit Dutta
Ankit Dutta il 18 Feb 2019
I hope you have already tried changing the different parameters available for smoothening the curve using "smoothing spline" function. You can refer to this link for more information.
Other than “smoothing spline” these methods can be used for smoothing and fitting the curve to data:
  • Interpolation Methods Estimating data between known data points
  • Lowess Smoothing Create a smooth surface using locally weighted linear regression to smooth data.
  • Filtering and Smoothing Data Using smooth function using methods for moving average, Savitzky-Golay filters, and local regression with and without weights and robustness
  1 Commento
Erialett Fernandez
Erialett Fernandez il 5 Mar 2020
Can you post an example, please? I have followed the directions in these links but not sure what I'm missing and why it doesn't work on semilogx.

Accedi per commentare.

Prodotti


Release

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by