Increase a variable by 0.1 each iteration
Show older comments
I have created code to find Scrit and Dmax for a series of Dd values, but each iteration seems to increase by a random amount - I need it to increase by 0.1 each time? I believe I need to edit the line i=0.01:0.1:1?
I would also like to be able to save each iteration table in a new excel row, but at the moment the code just overwrites into the first row of my excel spreadsheet?
T=table(Dd, Scrit, Dmax)
filename='Dry diameter.xls';
writetable(T,filename)
- do I need to edit this to new column each run, if so how?
Here is the code:
% Using dry diameter in um
K=0.5;
sigma=0.072;
T=298.15;
Mw=18.01528;
Pw=0.997;
R=8.3143;
x=(4*sigma*Mw)/((R*T*Pw));
Dd=0.1
for i=0.01:0.1:1
Dd=Dd+i
D=linspace(Dd,2,10);
S=((D.^3-Dd^3)./(D.^3-Dd^3+Dd^3*K)).*exp(x./D)
Scrit=max(S)
Dmax=D(find(S==Scrit))
T=table(Dd, Scrit, Dmax)
filename='Dry diameter.xls';
writetable(T,filename)
end
2 Comments
I have formatted your code toda to make it readable. Please do this by your own in future questions. Thanks.
"but each iteration seems to increase by a random amount" - why do you assume this? What do you observe?
" I believe I need to edit the line i=0.01:0.1:1" - why?
Alice Cozens
on 4 Mar 2019
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!