Why am I getting this error?
显示 更早的评论
There must be Error using fprintf
Unable to convert 'sym' value to 'double'.
Error (line 65)
fprintf('There must be %4.2f moles of NH3 produced to raise the blood pH back to a normal 7.4. \n',Z(1));
Why am I receiving this error??
Code:
% Assume: Open, Reactive, Dynamic
% Basis/Given:
Ka=5.6*10^-10; %M
Vblood= 5000; %mL
pHi=7.2;
pHf=7.4;
mAo=(60/100)*Vblood; %ug
MWnh4=18039000 %um/mol
nAo=mAo/MWnh4
nHo=10^(-pHi)*Vblood;
nHf=10^(-pHf)*Vblood;
% HA: nHAq=nHAf-nHAo
% H: -nHc=nHf-nHo
% A: nAi-nAc=nAf
%%Calculate:
syms nHAo Kap nHo nAo
E1=Kap==Vblood*Ka;
E1a=Kap ==((nHo*nAo)/nHAo);
E1b=nAo==mAo/MWnh4;
E1c=nHo==10^(-pHi)*Vblood;
X=solve(E1,E1a,E1b,E1c,nHAo,Kap,nHo,nAo);
nHAo=X.nHAo;
%n.Hi-n.Hc=n.Hf-n.Ho
%-n.Ac=n.Af-n.A0
%n.HAg=n.HAf-n.HAo
%Kap=(n.hf*n.Af)/n.HAf
%n.Hc=n.Ac
%n.Ac=n.HAg
Kap=Vblood*Ka;
nAo=mAo/MWnh4;
nHo=10^(-pHi)*Vblood;
M=[1,-1,0,0,0,0;
0,0,-1,-1,0,0;
0,0,0,0,1,-1;
0,0,0,-nHf,0,Kap;
0,1,-1,0,0,0;
0,0,1,0,-1,0];
b=[nHf-nHo;
-nAo;
-nHAo;
0;
0;
0];
Z=M\b;
Z(1)
%%Finalize:
fprintf('There must be %4.2f moles of NH3 produced to raise the blood pH back to a normal 7.4. \n',Z(1));
4 个评论
Star Strider
2018-4-18
I can’t run this in R2018a.
You did not define ‘pHo’ in the code you posted, so there are no solutions for ‘X’, ‘nHAo’ does not exist, and the rest of the code fails.
Since I don’t have the necessary information to run your code, my best guess is that ‘Z(1)’ contains a symbolic variable, and that’s the reason that double can’t convert it.
Star Strider
2021-8-12
In the absence of new information, my 3½-year-old Answer remains the same.
.
Nicole Haikalis
2021-8-12
Star Strider
2021-8-12
As always, my pleasure!
.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Common Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!