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!