Fitting implicit surface equation

2 views (last 30 days)
Moritz
Moritz on 13 Dec 2013
Dear all,
following problem: I do have a 5x4 Matrix q(C,Cna) and would like to fit the implicit expression defined in the funktion SMAexplizit. I use lsqcurvefit, but i also tried fminunc fminsearch etc. I would like to use fit but i do not understand how to construct a fittype object with my function.
I do get results and the plot of the fit looks ok but i never come close to the inital parameters.
Any Suggestions why this happens ?
clear all
close all
clc
%%Makes a set of test data
p=[10 3 12]';
q0=635;
Cna=linspace(50,500,4)'; %Salt concentration
C=linspace(0.01,2,5)'; % Protein concentration
q=SMAexplizit(q0,p,C,Cna) % Calculated Isotherm Data for parameter p
qmeasured=q+5*rand(size(q,1),size(q,2)); % add noise
Testfit=lsqcurvefit(@(p,C)SMAexplizit(q0,p,C,Cna),p,C,qmeasured,[0.001 0.001 1],[100 50 50])
function q=SMAexplizit(q0,p,C,Cna)
%%solves the SMA model near the point 0.001 and makes an explizit
%%expression for every data point C.
% global q0
Ke=p(1);
sigma=p(2);
z=p(3);
q=zeros(size(C));
NN=length(C);
opt = optimset('display','off');
for n=1:length(Cna)
for i=1:NN
q(i,n)=fsolve(@(q)Ke*(q0-(z+sigma).*q).^z.*C(i)./(Cna(n).^z)-q,0.001,opt);
end
end
end

Answers (0)

Categories

Find more on Linear and Nonlinear Regression in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!