I'm trying to figure out a simple code to plot supersaturation values against the size of a particle. I have everything I need, just having trouble plotting multiple values for the radius. I'm using a loop as it seems the most logical when plotting so many values.
T = 293;
k = 1.38*10^-23;
o = 75.64*10^-3;
n = 3.348*10^28;
Ms = .13214;
Mw = .018;
p = 1769;
i = 3;
m=10^-16;
EIndex = 1
for r = 0.01:100
E(EIndex) = (exp((2*o)/(n*k*T*r)))*((1+((i*m*Mw)/(Ms*(((4/3)*pi*(r^3)*p)-m))))^-1)
EIndex = EIndex + 1
S(EIndex)=100*E - 100;
end
semilogx(S)
xlim([0.01 100])
ylim([-1.5 0.5])
I've tried various setups and get error such as "indices need to be positive" or the current "In an assignment A(:) = B, the number of elements in A and B must be the same."
Simply put I want to
  1. plot values for r (radius) on the x axis logarithmic from .01 - 100
  2. plot values for S (supersaturation) on the y axis linearly from 80-100.5%
The end result should look like a Kohler curve similar to below
Any help would be greatly appreciated!

1 件のコメント

Jakub Bialek
Jakub Bialek 2016 年 11 月 18 日
Tiki did you manage to produce similar graphs for your AS solution? I mean for different Dp... How do oyu specify Dp?

サインインしてコメントする。

 採用された回答

Star Strider
Star Strider 2015 年 11 月 19 日

1 投票

This eliminates the loop but doesn’t produce the plot you want. (The plot actually looks as though it’s inverted.) What equation are you coding?
T = 293;
k = 1.38E-23;
o = 75.64E-3;
n = 3.348E28;
Ms = .13214;
Mw = .018;
p = 1769;
i = 3;
m=1E-16;
r = linspace(1E-6, 1E-4, 1000);
E = 1./(exp((2*o)./(n*k*T*r))).*((1+((i.*m.*Mw)./(Ms.*(((4/3)*pi*(r.^3).*p)-m)))));
S = 100*E - 100;
figure(1)
semilogx(r, S)

7 件のコメント

Tiki
Tiki 2015 年 11 月 19 日
Here is the equation.
E = [exp(2o/nkTr)] * [1 + (imMw)/Ms{(4/3)(pi)(r^3)(p)-m}]^-1]
Sorry just realized I left out the ^-1 at the end. That actually puts the curve right side up.
Thank you for eliminating the loop, I tried that to start and couldn't even get a curve to appear.
Now I'm just looking to have the x axis be values scaled logarithmic-ally from .01-100 and the y axis values in percent from 80 - 100.5
Star Strider
Star Strider 2015 年 11 月 19 日
Yoyu didn’t leave it out, I miscounted parentheses and put the division in the wrong place. The ‘E’ assignment should be:
E = (exp((2*o)./(n*k*T*r))).*(1./(1+((i.*m.*Mw)./(Ms.*(((4/3)*pi*(r.^3).*p)-m)))));
The entire code seems to produce the sort of plot you want:
T = 293;
k = 1.38E-23;
o = 75.64E-3;
n = 3.348E28;
Ms = .13214;
Mw = .018;
p = 1769;
i = 3;
m=1E-16;
r = linspace(9E-7, 1E-4, 1000);
E = (exp((2*o)./(n*k*T*r))).*(1./(1+((i.*m.*Mw)./(Ms.*(((4/3)*pi*(r.^3).*p)-m)))));
S = 100*E - 100;
figure(1)
semilogx(r, S)
xlim([0.1 100]*1E-6)
ylim([-0.5 0.5])
xtk = get(gca, 'XTick');
set(gca, 'Xtick',[xtk xtk(end)*10], 'XTickLabel',[xtk xtk(end)*10]*1E+6)
xlabel('Wet Diameter (\mum)')
ylabel('Supersaturation (%)')
Tiki
Tiki 2015 年 11 月 19 日
Perfect. Thank you so much for your help!
Star Strider
Star Strider 2015 年 11 月 19 日
Thank you. My pleasure!
Nur Fabien Idrissa
Nur Fabien Idrissa 2018 年 12 月 5 日
編集済み: Nur Fabien Idrissa 2018 年 12 月 5 日
can you show the equation presented in the above solution.
thanks.
is it like this?Screenshot_4.png
Rik
Rik 2018 年 12 月 5 日
@Nur, please don't use flags for comments. You should only flag an answer/comment if it requires attention from staff members.
Star Strider
Star Strider 2018 年 12 月 5 日
@Nur Fabien Idrissa — I have no idea. Look at it to see if it matches.
@Rik — Thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

質問済み:

2015 年 11 月 19 日

コメント済み:

2018 年 12 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by