Creating a loop to simulate model
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
user
am 4 Sep. 2022
Beantwortet: Walter Roberson
am 4 Sep. 2022
Hello,
I am seeking to create a loop that simulates the following function, while keeping track of its output. The code i have provided has a boolean output (Response) of either 0 or 1 and I would like to be able to simulate the model described in my code a large number of times while keeping track of the frequency of each boolean output. Any help would be appreciated.
function Response = testingforparam
r1 = unifrnd(0.27, 1.06)
r2 = unifrnd(0.57, 1.30)
function C=kinetics(theta,t)
%c0 denotes the intial conditions of each compartment
c0=[0;0;(100)];
[T,Cv]=ode45(@DifEq,t,c0);
function dC=DifEq(t,c)
dcdt=zeros(3,1);
dcdt(1)= 20.*c(3)+(r1).*c(1).*(1-(c(1)/(5*10^9)))-0.02.*c(1)-((69.7).*c(1)/(1+0.01*c(1)));
dcdt(2)= 20.*c(3)+(r2).*c(2).*(1-(c(2)/(1*10^9)))-0.02.*c(2)-((9/11)*(57.02).*c(2)/(1+0.01*c(2)));
dcdt(3)= 0.02.*c(1)+0.02.*c(2)-20.*c(3)-20.*c(3)-39.12.*c(3);
dC=dcdt;
end
C=Cv;
end
%The following is the data obtained by Join-Lambert et al used in fitting
%the model
t = [0,0.3,24,48];
Liver = [0;101329.8755;9983499.7496;3397799162.7540];
Spleen = [0;365778.6821;7088832.4672;169779424.6359];
Blood = [0;23.2338;92.2555;16841.2063];
c = [Liver, Spleen, Blood];
theta0=[1;1;1];
[theta,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat]=lsqcurvefit(@kinetics,theta0,t,c);
tv = linspace(min(t), max(t), 4);
Fit = kinetics(theta, tv);
LiverFit = Fit(:,1);
SpleenFit = Fit(:,2);
BloodFit = Fit(:,3);
Final = (LiverFit(end)+SpleenFit(end)+BloodFit(end));
% Using boolean notation, 1 is a positive reponse, 0 is a zero reponse
if Final>2 Response = 1;
else Response = 0;
end;
end
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 4 Sep. 2022
N = 5000;
Responses = zeros(N, 1);
for K = 1 : N
Responses(K) = testingforparam;
end
mean_ones = mean(Responses);
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Cardiology 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!