Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
fitting implzit equation (steric mass action model) as surface fit

Subject: fitting implzit equation (steric mass action model) as surface fit

From: Moritz

Date: 24 May, 2013 15:15:10

Message: 1 of 2

Dear all,

the steric mass action model is an implizit equation

q=K*(q0-(z+sigma)*q)^z*C/Csalt^z

q...[mg/mL] bound protein
C...[mg/mL] free Protein
q0..exchange capacity of ion exchanger [microEqu/mL]
z..effective net charge of protein
sigma..steric shielding parameter
K..Equilibrium constant

fitting parameters are z, sigma and K

It is not very difficult to fit the parameters to data (Thanks to this post: http://learn-one-thing-a-day.blogspot.co.at/2012/07/how-to-fit-implicit-function-with-matlab.html)

I would like to fit a surface with the sodium concentration as the second independend Parameter (the first is C). Any hints ? Can i still do it that way ? Just expanding the vector to a matrix ?

Here is my code for the 2D Problem:

[QUOTE]
function q=SMAexplizit(p,C,q0,Cna)
%%solves the SMA model near the point 0.001 and makes an explizit
%%expression for every data point C.
Ke=p(1);
sigma=p(2);
z=p(3);
q=zeros(size(C));
NN=length(C);
opt = optimset('display','off');
for i=1:NN
    q(i)=fsolve(@(q)Ke*(q0-(z+sigma).*q).^z.*C(i)./(Cna.^z)-q,0.001,opt);
end

end
[\QUOTE]

[QUOTE]
%% Makes a set of test data
p=[0.2 5.7 9.1];
q0=635;
Cna=25;
C=linspace(0.01,2,20);
q=SMAexplizit(p,C,q0,Cna)

%% Fits the data with initial guess
% Data=xlsread('TestSMA.xls');
% Cmeasured=Data(:,1);
% qmeasured=Data(:,2);
p=[1 10 6];
Xfit=lsqcurvefit(@(p,C)SMAexplizit(p,C,q0,Cna),p,C,q)
%% Plots the fit
qhat=SMAexplizit(Xfit,C,q0,Cna)
plot(C,q,'*r')
hold on
plot(C,qhat,'b')
[\QUOTE]

Subject: fitting implzit equation (steric mass action model) as surface fit

From: Moritz

Date: 24 May, 2013 15:42:09

Message: 2 of 2

"Moritz" wrote in message <kno05u$mmm$1@newscl01ah.mathworks.com>...
> Dear all,
>
> the steric mass action model is an implizit equation
>
> q=K*(q0-(z+sigma)*q)^z*C/Csalt^z
>
> q...[mg/mL] bound protein
> C...[mg/mL] free Protein
> q0..exchange capacity of ion exchanger [microEqu/mL]
> z..effective net charge of protein
> sigma..steric shielding parameter
> K..Equilibrium constant
>
> fitting parameters are z, sigma and K
>
> It is not very difficult to fit the parameters to data (Thanks to this post: http://learn-one-thing-a-day.blogspot.co.at/2012/07/how-to-fit-implicit-function-with-matlab.html)
>
> I would like to fit a surface with the sodium concentration as the second independend Parameter (the first is C). Any hints ? Can i still do it that way ? Just expanding the vector to a matrix ?
>
> Here is my code for the 2D Problem:
>
> [QUOTE]
> function q=SMAexplizit(p,C,q0,Cna)
> %%solves the SMA model near the point 0.001 and makes an explizit
> %%expression for every data point C.
> Ke=p(1);
> sigma=p(2);
> z=p(3);
> q=zeros(size(C));
> NN=length(C);
> opt = optimset('display','off');
> for i=1:NN
> q(i)=fsolve(@(q)Ke*(q0-(z+sigma).*q).^z.*C(i)./(Cna.^z)-q,0.001,opt);
> end
>
> end
> [\QUOTE]
>
> [QUOTE]
> %% Makes a set of test data
> p=[0.2 5.7 9.1];
> q0=635;
> Cna=25;
> C=linspace(0.01,2,20);
> q=SMAexplizit(p,C,q0,Cna)
>
> %% Fits the data with initial guess
> % Data=xlsread('TestSMA.xls');
> % Cmeasured=Data(:,1);
> % qmeasured=Data(:,2);
> p=[1 10 6];
> Xfit=lsqcurvefit(@(p,C)SMAexplizit(p,C,q0,Cna),p,C,q)
> %% Plots the fit
> qhat=SMAexplizit(Xfit,C,q0,Cna)
> plot(C,q,'*r')
> hold on
> plot(C,qhat,'b')
> [\QUOTE]

Well i figured it out. Just looping over length(Cna) and fitting as usual. lb and upper bounds helped.

Any suggestions (aside of avoiding implizit versions of this function) how tho speed it up. or is this way ok ? Writing slow code is rather easy i figured out :)

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us