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

11 次查看(过去 30 天)
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 个评论
Erialett Fernandez
编辑:Erialett Fernandez 2020-3-5
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.

请先登录,再进行评论。

回答(1 个)

Ankit Dutta
Ankit Dutta 2019-2-18
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 个评论
Erialett Fernandez
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by