displaying values in command window

1 次查看(过去 30 天)
follow script, how do i display the value of Vb and pH when "abs(M_excess)<eps" and following that how would i plot that point a figure.
Kw = 1e-14;
Ka = 1.755388e-5;
pKa = 4.756;
%
Ca = 0.5;
Cb = 0.1;
Va = 100;
Vb = 0.05:0.05:2000;
%
% This simulates initial molarity of CH3CO2H.
Ma = (Ca * Va) / 1000;
% This simulates initial molarity of NaOH.
Mb = (Cb .* Vb) ./ 1000;
for i = 1:length(Mb)
M_excess = Ma - Mb(i);
if abs(M_excess)<eps
Hplus = Ka * ((Ma_final * 0.999999) ./ Mb_final);
elseif M_excess > 0
Ma_final = (M_excess * 1000) ./ (Va + Vb(i));
Mb_final = (Mb(i) * 1000) ./ (Va + Vb(i));
Hplus = Ka * (Ma_final ./ Mb_final);
elseif M_excess < 0
OH = (M_excess * 1000 * (-1)) ./ (Va + Vb(i));
Hplus = Kw ./ OH;
end
pH(i) = -log10(Hplus);
end

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2013-8-5
for i = 1:length(Mb)
M_excess = Ma - Mb(i);
v=[];
if abs(M_excess)<eps
Hplus = Ka * ((Ma_final * 0.999999) ./ Mb_final);
v(end+1)=Hplus,
elseif M_excess > 0
Ma_final = (M_excess * 1000) ./ (Va + Vb(i));
Mb_final = (Mb(i) * 1000) ./ (Va + Vb(i));
Hplus = Ka * (Ma_final ./ Mb_final);
elseif M_excess < 0
OH = (M_excess * 1000 * (-1)) ./ (Va + Vb(i));
Hplus = Kw ./ OH;
end
pH(i) = -log10(Hplus);
end
display(v)
  5 个评论
Azzi Abdelmalek
Azzi Abdelmalek 2013-8-5
display(Vb')
display(pH')
% or you can display them together
[Vb' pH']
harley
harley 2013-8-5
编辑:Azzi Abdelmalek 2013-8-5
i think i got it to work Azzi. Thanks for your help, its been great.
for i = 1:length(Mb)
M_excess = Ma - Mb(i);
if abs(M_excess)<eps
Hplus = Ka * ((Ma_final * 0.999999) ./ Mb_final);
pH_ev = pH(end);
Vb_ev = Vb(i);
elseif M_excess > 0
Ma_final = (M_excess * 1000) ./ (Va + Vb(i));
Mb_final = (Mb(i) * 1000) ./ (Va + Vb(i));
Hplus = Ka * (Ma_final ./ Mb_final);
elseif M_excess < 0
OH = (M_excess * 1000 * (-1)) ./ (Va + Vb(i));
Hplus = Kw ./ OH;
end
pH(i) = -log10(Hplus);
end
% OUTPUT SECTION
disp('The Volume of Base NaOH at Equivalence is:')
disp(Vb_ev)
disp('The pH at Equivalence is:')
disp(pH_ev)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by