Fitting two data sets with different equation but same parameters

13 ビュー (過去 30 日間)
Jennifer Yu
Jennifer Yu 2013 年 7 月 8 日
Hi everyone,
I have a problem on my hands that I don't really know how to solve. I have two sets of data, one is Amplitude vs Temeprature (let's called it Amp vs Temp) and another is Phase vs Temperature (say Phi vs Temp). Right now I need to fit a non-linear model to Amp vs Temp, let's say for simplicity
Amp(Temp) = a*Temp^2+b*Temp^3, a
nd a different model to Phi vs Temp, let's say
Phi(Temp) = a*exp(-b*Temp).
But a and b are the same for both Amp and Phi because they are actual physical quantities. How should I proceed?
Thank you very much!
Jennifer

採用された回答

Shashank Prasanna
Shashank Prasanna 2013 年 7 月 8 日
Jennifer, essentially you are solving a system of equations. Do you have the optimization toolbox? If you do then you can solve this either using fsolve or lsqnonlin
Create a function as follows:
function y = nonlinmodel(x,Temp,Amp,Phi)
y = [Amp - x(1)*Temp.^2 + x(2)*Temp.^3; Phi - x(1)*exp(-x(2)*Temp)];
% Where x(1) = a, and x(2) = b
Now you want to find x(1) and x(2) that minimizes the above system in a least square sense.
Temp = randn(100,1);
Amp = randn(100,1);
Phi = randn(100,1);
% Some random data for demonstration
f = @(x)nonlinmodel(x,Temp,Amp,Phi);
optimal_x = lsqnonlin(f,[0;0]);
% OR
optimal_x = fsolve(f,[0;0]);
  2 件のコメント
Shashank Prasanna
Shashank Prasanna 2013 年 7 月 8 日
Jennifer Yu
Jennifer Yu 2013 年 7 月 9 日
That's exactly what I'm looking for. Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFit Postprocessing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by