필터 지우기
필터 지우기

Fitting a curve to data

조회 수: 1 (최근 30일)
A
A 2012년 6월 19일
Hello,
I am trying to test out the validity of Taylor-Sedov analytical solution to an experimental data set.
I want to fit curves of the form
y=At^2
y=At^3
to some data points, where A is malleable and will be changed to achieve the best fit.
Advice is greatly appreciated.

답변 (1개)

the cyclist
the cyclist 2012년 6월 20일
If you have the Statistics Toolbox, you can use the nlinfit() function. Here is an example of doing the fit with Ax^2. It should be obvious how to adapt it for Ax^3.
% Here is an example of using nlinfit(). For simplicity, none of
% of the fitted parameters are actually nonlinear!
% Define the data to be fit
x=(0:1:10)'; % Explanatory variable
y = 7*x.^2; % Response variable (if response were perfect)
y = y + 15*randn((size(x)));% Add some noise to response variable
% Define function that will be used to fit data
% (F is a vector of fitting parameters)
f = @(A,x) A.*x.^2;
A_fitted = nlinfit(x,y,f,[1]);
% Display fitted coefficients
disp(['A = ',num2str(A_fitted)])
% Plot the data and fit
figure(1)
plot(x,y,'*',x,f(A_fitted,x),'g');
legend('data','fit')

카테고리

Help CenterFile Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by