How to repeat and store multiple calculations of vpasolve function in terms of adjusting a variable in the equation

3 次查看(过去 30 天)
Asat = 16.3872;
Bsat = 3885.7;
Csat = 230.16;
w0 = 0.38;
En = 220;
n = 1.1;
MWwater = 18.01528;
% (*g/mol*)
R = 8.3145/MWwater;
T0 =4 + 273.15;
Tend = 62 + 273.15;
T = T0;
w = 0.05;
Psat = exp((Asat)- ((Bsat)/(T + Csat - 273.15)));
syms P
S = vpasolvevpasolve(w0*exp(-(((-R*T)*log(P/Psat))/(En))^n)== w, P,'Random',true)
%so if you run this code, S=0.030865627730443770149747137911306
% i want to know how to integrate this solution in a Loop where i can %increase initial tempreture (T0) and store the new solution until it reach %the maximum tempreture (Tend). where it will give me series of %Numerical solutions at each time i will change based on a loop.
%I dont know how to integrate the loop in this code,
%could you please help me here,
%Thanks.

回答(1 个)

Jyotsna Talluri
Jyotsna Talluri 2019-11-7
Solve the equation for each value of T in a for loop by storing the solved value in a array each time
val=[];
for T= T0:5:Tend
Psat = exp((Asat)- ((Bsat)/(T + Csat - 273.15)));
syms P
S = vpasolve(w0*exp(-(((-R*T)*log(P/Psat))/(En))^n)== w, P,'Random',true);
val(end+1)=S;
end

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by