Index exceeds the number of array elements. Index must not exceed 1.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
function ans = final_project()
CI_CO2 = [0,10];
Y0 = [0.0001,0.0001,0.0001,0.0001,0.0001,0.0001,4.75,0.7];
options = odeset('RelTol', 1e-10,'AbsTol',[1e-10,1e-10,1e-10]);
[CI_CO2,VA] = ode45(@respiratory_model,CI_CO2,Y0,options);
plot(CI_CO2,VA)
function res = respiratory_model(CI_CO2,VA)
MT_CO2 = 0.221; MT_O2 = 0.221; MB_CO2 = 0.042; MB_O2 = 0.042; PB = 760; k1 = 0.107;
k2 = 0.415; k3 = 0.2; k4 = 0.05; k5 = 0.92; h = 820067507; u = -148822662; v = 9.8949e+06;
p = -2.7670e+05; q = 3.3179e+03; r = 43; f = 0.003; s = 2.3; g = 98; W = 0.014; S = 0.024;
a = 99; b = 19.6; d = 0.0008; n = 3; m = 98;
Q = 6; QB = 0.7; QBN = 1; CB_CO2 = 55.9; CB_O2 = 0.110; CA_CO2 = 5.6; CA_O2 = 14.1; CT_CO2 = 54;
CT_O2 = 0.134; CI_O2 = 0.1967;
eq58 = MB_CO2 + QB*(k1*(PB*CA_CO2)^k2) - CB_CO2;
eq59 = MT_CO2 + (Q-QB)*(k1*(PB*CA_CO2)^k2-CT_CO2);
eq60 = QB*(CB_CO2-CT_CO2) + Q*(CT_CO2-k1*(PB*CA_CO2)^k2) + VA*(CI_CO2-CA_CO2);
eq61 = -MB_O2 + k3*QB*((1-exp(-k4*k5*PB*CA_O2))^2 - (1-exp(-k4*PB*CB_O2/S))^2);
eq62 = -MT_O2 + k3*(Q-QB)*((1-exp(-k4*k5*PB*CA_O2))^2 - (1-exp(-k4*PB*CT_O2/S))^2);
eq63 = -k3*QB*((1-exp(-k4*PB*CB_O2/S))^2 - (1-exp(-k4*PB*CT_O2/S))^2) + k3*Q*((1-exp(-k4*PB*CT_O2/S))^2 - (1-exp(-k4*k5*PB*CA_O2))^2) + VA*(CI_O2-CA_O2);
eq64 = -VA + a*(CB_CO2)^(1/k2) - b + d*(m-k5*PB*CA_O2)^n;
eq65 = -QB + W*(h*(CA_CO2)^5 + u*(CA_CO2)^4 +v*(CA_CO2)^3 + p*(CA_CO2)^2 + q*CA_CO2 + r + f*(g-1/k5(PB*CA_O2))^8) + QBN;
res = [eq58; eq59; eq60; eq61; eq62; eq63; eq64; eq65];
end
end
Trying to obtain a plot to see how different CI_CO2 (x-variable) values effect VA (y-variable), which is solved from this system of equations. Any help would be greatly appreciated, thank you!
2 Commenti
DGM
il 27 Nov 2021
This is an indexing operation into a scalar:
(g-1/k5(PB*CA_O2))^8
is this supposed to be a multiplication operation?
(g-1/k5*(PB*CA_O2))^8
or
(g-1/(k5*PB*CA_O2))^8
?
Risposte (1)
Cris LaPierre
il 28 Dic 2021
Modificato: Cris LaPierre
il 28 Dic 2021
The issue is that eq60, eq63 and eq64 are returning 8x1 vectors. That adds 24 items to your ouput vector. Plus the scalar values from the other equations gives you 29 items.
This is because you are using your vector of ICs VA in these equations. We don't have the original equations to know what the correct value here should be, but it is likely you are supposed to index just one of the VA values in each equation.
0 Commenti
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!