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
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 Exchange에서 Loops 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