displaying indexed values correctly
이전 댓글 표시
hi, trying to display some values but am not sure how to go about it. I want to do is; find Vb at half of Vb_ev and then find the corresponding pH value at that point. see last 2 lines. any help will be appreciated.
format short
Kw = 1e-14;
Ka = 1.755388e-5;
Ca = 0.5;
Cb = 0.1;
Va = 100;
Vb = 0.05:0.05:2000;
Ma = (Ca * Va) / 1000;
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);
Vb_ev = Vb(i);
pH_ev = pH(end);
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
%
%
Vb_Mid_Pt1 = uint16(Vb_ev)*0.5;
pH_Mid_Pt1 = pH(Vb_Mid_Pt1)
i tried the above but the pH_Mid_Pt1 gives me the value in the pH array that is equal to the actual numerical value of that from (Vb_ev)*0.5.
댓글 수: 9
Azzi Abdelmalek
2013년 8월 7일
I think, you can make your question easier, by giving a short example that you can adapt to your problem
harley
2013년 8월 7일
Walter Roberson
2013년 8월 7일
When you say "half" do you mean the point at which it is 1/2 of the maximum value, or do you mean the point that is half way through the vector ?
harley
2013년 8월 7일
Walter Roberson
2013년 8월 7일
Suppose Vb_ev is 0.9 . Then Vb_ev/2 is 0.45. But there is no Vb that is 0.45 . What do you want to do in such a case? And what if Vb_en is 0.1 the very first Vb value ?
harley
2013년 8월 7일
Walter Roberson
2013년 8월 7일
If half Vb_ev is 250 then is Ph(250) what you want returned? If so then why do you consider your current code to be incorrect?
Are you looking for the point in Ph that is closest to Ph(Vb_ev)/2 ?
harley
2013년 8월 7일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!