現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
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
採用された回答
Azzi Abdelmalek
2013 年 8 月 4 日
編集済み: Azzi Abdelmalek
2013 年 8 月 4 日
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 件のコメント
harley
2013 年 8 月 5 日
thanks Azzi, still skips the calc when M_excess = 0. Any other thoughts?
harley
2013 年 8 月 5 日
Alternatively if M_excess = 0 is there a way to tell it to use the pH and Vb calculated in the iteration?
Azzi Abdelmalek
2013 年 8 月 5 日
編集済み: Azzi Abdelmalek
2013 年 8 月 5 日
Because M_excess is never equal to 0, you can check it by
any(Ma - Mb==0) % you will find 0
harley
2013 年 8 月 5 日
i see, i that because no array is created for M_excess? any thoughts on getting around this would be greatly appreciated, don't mind if i have to re write the script.
harley
2013 年 8 月 5 日
if this helps it calc Hplus when Ma = Mb
Azzi Abdelmalek
2013 年 8 月 5 日
In your case Ma is never equal to Mb
harley
2013 年 8 月 5 日
thanks for your time Azzi, very new to matlab Ma = 0.05 in my Mb array i have Mb = 0.05 at row 10000? sorry i am having trouble understanding matlab logic.
Azzi Abdelmalek
2013 年 8 月 5 日
Ok, First, it's not row 10000, but 5000
Mb(5000)
Now type
a=Mb(5000)
The result is 0.0500
Now try
a==0.05
You will find 0, which means they are not equals.
You can also try this
0.3-0.2==0.1 % the result is false
To understand what is going on look at this link
harley
2013 年 8 月 5 日
sorry for the confusion, yes you are right row 5000. I kind of understand what's happening now, so do i need to specfic a tolerance? Thanks for your time again.
Azzi Abdelmalek
2013 年 8 月 5 日
You should use some tolerence
find(abs(Mb-Ma)<eps)
harley
2013 年 8 月 5 日
Thanks Azzi how have been extremely helpful, how do i apply that 'find(abs(Mb-Ma)<eps)' to your edited script.
Azzi Abdelmalek
2013 年 8 月 5 日
編集済み: Azzi Abdelmalek
2013 年 8 月 5 日
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);
harley
2013 年 8 月 5 日
thank you very much, all working now.
harley
2013 年 8 月 5 日
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.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Timing and presenting 2D and 3D stimuli についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
