필터 지우기
필터 지우기

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

조회 수: 18 (최근 30일)
Evan Rose
Evan Rose 2019년 2월 6일
댓글: Erialett Fernandez 2020년 3월 5일
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일
편집: 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
Erialett Fernandez 2020년 3월 5일
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에서 Smoothing에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by