Fitting two data sets with different equation but same parameters

16 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

Shashank Prasanna
Shashank Prasanna am 8 Jul. 2013
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]);

Weitere Antworten (0)

Kategorien

Mehr zu Fit Postprocessing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by