Filter löschen
Filter löschen

loops for if, ifelse, end

8 Ansichten (letzte 30 Tage)
harley
harley am 4 Aug. 2013
i have the script and i want to add three condition, not sure how to do it.
Kw = 1e-14;
Ka = 1.755388e-5;
pKa = 4.756;
%
Ca = 0.5;
Cb = 0.1;
Va = 100;
Vb = 0.1:0.1:1500;
%
Ma = (Ca * Va) / 1000;
%
Mb = (Cb .* Vb) ./ 1000;
%
for i = 1:length(Mb)
M_excess = Ma - Mb(i);
this is where im stuck!!!!!!!!!
if 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);
if M_excess < 0
OH = (M_excess * 1000 * (-1)) ./ (Va + Vb(i));
Hplus = Kw ./ OH;
if M_excess = 0
Hplus = Ka * ((Ma_final * 0.999999) ./ Mb_final); ./ (Va + Vb(i));
end
pH(i) = -log10(Hplus);
end

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 4 Aug. 2013
Bearbeitet: Azzi Abdelmalek am 4 Aug. 2013
if 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;
else
Hplus = Ka * ((Ma_final * 0.999999) ./ Mb_final);
end
pH(i) = -log10(Hplus);
  14 Kommentare
harley
harley am 5 Aug. 2013
thank you very much, all working now.
harley
harley am 5 Aug. 2013
a minor question. How do i display the pH and Vb value at the point of abs(M_excess)<eps. I also want to plot the pH on figure 1.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by