matlab - Plot of two variables varied simultaneously, on x-axis -
my following code generates graph looping variable x-axis. specifically, eta_22 varies 0 1, loop iteration size of 0.01.
the code below line source function file.
my question is: how can generate graph eta_1 varying 0 1, loop iteration size of 0.01 well? (i want plot of aa on y-axis, , eta_1, eta_2 varying 0 1.)
my attempts: have tried create nested "for" loops, plot looping. have tried put plot line outside of "for" loops well, did not work.
thanks help.
global lambda mu mu_a mu_t beta tau eta_1 eta_2 lambda_t rho_1 rho_2 gamma alpha = 100; time = 365; eta_22 = zeros(1,alpha); aa = zeros(1,alpha); m = 1:1:alpha eta_2 = m./alpha; eta_22(m) = m./alpha; lambda = 531062; mu = (1/70)/365; mu_a = 0.25/365; mu_t = 0.2/365; beta = 0.187/365; tau = 4/365; lambda_t = 0.1; rho_1 = 1/60; rho_2 = (rho_1)./(270.*rho_1-1); gamma = 1e-3; eta_1 = 0; s0 = 191564208; t0 = 131533276; h0 = 2405659; c0 = 1805024; c10 = 1000000; c20 = 1000000; ct10 = 500000; ct20 = 500000; y0 = [s0, t0, h0, c0, c10, c20, ct10, ct20]; [t,y] = ode45('simplifiedeqns',[0:1:time],y0); s = y(:,1); t = y(:,2); h = y(:,3); c = y(:,4); c1 = y(:,5); c2 = y(:,6); ct1 = y(:,7); ct2 = y(:,8); n = s + t + h + c + c1 + c2 + ct1 + ct2; hivinf1=[0:1:time]; hivinf2=[beta.*(s+t).*(c1+c2)./n]; hivinf=trapz(hivinf1,hivinf2); aa(m) = hivinf; end plot(100.*eta_22,aa./1000) _____________________________________________________________________________________________________ function ydot = simplifiedeqns(t,y) global lambda mu mu_a mu_t beta tau eta_1 eta_2 lambda_t rho_1 rho_2 gamma s = y(1); t = y(2); h = y(3); c = y(4); c1 = y(5); c2 = y(6); ct1 = y(7); ct2 = y(8); n = s + t + h + c + c1 + c2 + ct1 + ct2; ydot = zeros(8,1); ydot(1)=lambda-mu.*s-beta.*(h+c+c1+c2).*(s./n)-tau.*(t+c).*(s./n); ydot(2)=tau.*(t+c).*(s./n)-beta.*(h+c+c1+c2).*(t./n)-(mu+mu_t).*t; ydot(3)=beta.*(h+c+c1+c2).*(s./n)-tau.*(t+c).*(h./n)-(mu+mu_a).*h; ydot(4)=beta.*(h+c+c1+c2).*(t./n)+tau.*(t+c).*(h./n)-(mu+mu_a+mu_t+lambda_t).*c; ydot(5)=lambda_t.*c-(mu+mu_a+rho_1+eta_1).*c1; ydot(6)=rho_1.*c1-(mu+mu_a+rho_2+eta_2).*c2; ydot(7)=eta_1.*c1-(mu+rho_1+gamma).*ct1; ydot(8)=eta_2.*c2-(mu+rho_2+gamma.*(rho_1)./(rho_1+rho_2)).*ct2+(rho_1).*ct1; end
the simplest way:
eta_1=0:1/alpha:1; eta_2=0:1/alpha:1; lsize=length(eta_1) % assume eta_1 , eta_2 of same size i=1:lsize %update aa(i) here end plot(eta_1,aa,eta_2,aa)
Comments
Post a Comment