Fitting two data sets with different equation but same parameters

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

 采纳的回答

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]);

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by