displaying values in command window

21 Ansichten (letzte 30 Tage)
harley
harley am 5 Aug. 2013
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

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 5 Aug. 2013
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 Kommentare
Azzi Abdelmalek
Azzi Abdelmalek am 5 Aug. 2013
display(Vb')
display(pH')
% or you can display them together
[Vb' pH']
harley
harley am 5 Aug. 2013
Bearbeitet: Azzi Abdelmalek am 5 Aug. 2013
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)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by