Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: passing external parsmeter to nlmefitsa and ode45
Replies: 2   Last Post: Nov 28, 2012 3:32 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Edoardo

Posts: 8
Registered: 3/3/12
passing external parsmeter to nlmefitsa and ode45
Posted: Nov 19, 2012 3:33 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


Dear all,

I am facing the following problem: how to pass external parameters to the
@mymodel function used in the nlmefitsa function? (see below for specifications)

nlmefitsa(X,Y,Group,[],@mymodel,K0,...);

X is a 100 x 1 vector with time points (1:10) for 10 subjects
X is a 100 x 1 vector with measured concentration for 10 subjects

The mymdoel fucntion to be passed to the nlmefitsa solves a differential equation
trough the ode45. Anyway I need to pass the intial values "xin" (each individual has a different
starting value) to teh ode45 and moreover I need to pass also the matrix "external" which contains
data (NOT to be fitted) nedeed to the model. As I have 10 subjects I have 10 different "xin" vectors and matrices
"external" to be passed through the nlmefitsa to mymodelfun. How to pass this to nlmfitsa and how to tell him wihcih one to use?

Summarizing the problem is how to properly write the model function to be passed to nlmfitsa

I have tried everything I could think off but I am stuck. Does anybody have an idea? Or, is this possible to do?

Many thanks, any help is really appreciated
Edo


function YOUT = mymodel(K,xin,external)


[YOUT] = ode45(@(t,y) mydiffeq(t,y,K,external), [1 10], xin);


end



function dy = mydiffeq(t,y,K,external)


k1 = K(1);
k2 = K(2);
k3 = K(3);

time = external(:,1); %time points ext
conc = external(:,2); %concentrations

GG = interp1(time,conc, t);

% ode
dy = zeros(1,1);
dy(1) = (k1/(k2 + GG^k3))*y(1);
end



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.