How to iterate xa from 0 to 1 with steps of 0.05 in the function r=F*(k*C*(1-xa))/(1+K*C*(1-xa)). All variables are known except for r.
1 回表示 (過去 30 日間)
古いコメントを表示
I have to iterate the conversion of a reaction (x) in order to get the different values of catalyst mass (m).
The conversion 'x' would go from 0 to 1 with spaces of 0.05.
The function I need to iterate is: m=F*(k_kin*C*(1-x))/(1+k_ads*C*(1-x))
I know the value of all the variables except for m, which is the mass that I'd like to calculate.
F=0.11574; k_kin=1.3*10^-6; C=1.086; k_ads=0.9986
Please, help me. I haven't used matlab in years and I've forgotten how to make a 'for' loop work.
Thank you in advance.
採用された回答
Star Strider
2019 年 5 月 23 日
Everything except ‘x’ are scalars, so you can do this using a vectorization approach without the loop:
F=0.11574; k_kin=1.3*10^-6; C=1.086; k_ads=0.9986;
x = 0:0.05:1;
m=F*(k_kin*C*(1-x))./(1+k_ads*C*(1-x));
figure
plot(x, m)
grid
xlabel('Reaction')
ylabel('Catalyst Mass')
... including the plot! (Note the (./) denoting element-wise division.)
2 件のコメント
その他の回答 (2 件)
Geoff Hayes
2019 年 5 月 23 日
編集済み: Geoff Hayes
2019 年 5 月 23 日
Marina - try
m = zeros(20,1);
k = 1;
for x = 0:0.05:1
m(k) = F*(k_kin*C*(1-x))/(1+k_ads*C*(1-x))
k = k + 1;
end
edit to above: repalce == with = in assignment to m
8 件のコメント
Geoff Hayes
2019 年 5 月 23 日
where is x defined? I think you are missing
x = 0:0.05:1;
just prior to where you define m.
参考
カテゴリ
Help Center および File Exchange で Data Preprocessing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!