Plotting curves using loops?
Show older comments
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
- plot values for r (radius) on the x axis logarithmic from .01 - 100
- 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 Comment
Jakub Bialek
on 18 Nov 2016
Tiki did you manage to produce similar graphs for your AS solution? I mean for different Dp... How do oyu specify Dp?
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!