Clear Filters
Clear Filters

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

4 views (last 30 days)
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.

Answers (1)

Jyotsna Talluri
Jyotsna Talluri on 7 Nov 2019
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

Categories

Find more on Symbolic Math Toolbox 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!