I cannot solve the vpasolve using a symbolic function. Symbolic equal to Inf
3 views (last 30 days)
Show older comments
Hey there I really appreciate if someone can help. I have no ideia why I my symbolic equantion is Inf. I used the same scrip to solve another equation and it worked well.
Thanks in advance.
ds= 3;
rho_w= 3;
cp_w = 5;
hl_s = [2 , 2, 2, 2];
ls= 3;
mcv=9;
cp_al=7;
vs = [1, 2, 3, 4];
qs = pi*(ds/2)^2*vs;
%% Symbolic
tau_c_laminar = zeros(size(qs));
tau_s_laminar = zeros(size(qs));
ind = zeros(size(qs));
qcsolution_lam = zeros(size(qs));
qcsolutionlmin_lam = zeros(size(qs));
qcsolution_d_lam=[];
qclmin = qc*60000;
syms qcsyms qcsolution_lam
cont = 0;
range=[];
for i = 1:length(qs)
if Re_c(i) < 2300
fprintf("Re: %f \n",Re_c(i))
tau_c_laminar = (mwall*cp_al)/((rho_w*cp_w*qcsyms)*(1-exp((-hl_c(i)*pi*lc*dc)/(rho_w*cp_w*qcsyms))));%s
fprintf("talsym: %s \n", char(tau_c_laminar))
tau_s_laminar(i) = (mcv*cp_al)/((rho_w*cp_w*qs(i))*(1-exp((-hl_s(i)*pi*ls*ds)/(rho_w*cp_w*qs(i)))));%s
fprintf("taunum: %f \n",tau_s_laminar(i))
qcsolution_lam(i) = vpasolve (tau_c_laminar == tau_s_laminar(i));
fprintf("vpasolve: %f \n",qcsolution_lam(i))
end
end
The output is
Re: 433.464423
talsym: Inf % here I have no ideia why is like this
taunum: 1.437457
Error using sym/vpasolve (line 145)
Unable to find variables in equations.
Error in RASCUNHO (line 41)
qcsolution_lam(i) = vpasolve (tau_c_laminar == tau_s_laminar(i));
0 Comments
Answers (1)
Guru Mohanty
on 7 May 2020
Hi, I understand you are trying to solve these equations using vpasolve. In your code there are some undeclared variables as 'Re_c', 'qc', 'mwall', 'hl_c', 'lc', 'dc'. After declaring these variables the code is working. I have used random value for these variables. Here is the code for it.
Re_c=[100 200 300 433.464423 ];
qc=1;
mwall=1;
hl_c=1;
lc=1;
dc=1;
ds= 3;
rho_w= 3;
cp_w = 5;
hl_s = [2 , 2, 2, 2];
ls= 3;
mcv=9;
cp_al=7;
vs = [1, 2, 3, 4];
qs = pi*(ds/2)^2*vs;
%% Symbolic
tau_c_laminar = zeros(size(qs));
tau_s_laminar = zeros(size(qs));
ind = zeros(size(qs));
qcsolution_lam = zeros(size(qs));
qcsolutionlmin_lam = zeros(size(qs));
qcsolution_d_lam=[];
qclmin = qc*60000;
syms qcsyms qcsolution_lam
cont = 0;
range=[];
for i = 1:length(qs)
if Re_c(i) < 2300
fprintf("Re: %f \n",Re_c(i))
tau_c_laminar = (mwall*cp_al)/((rho_w*cp_w*qcsyms)*(1-exp((-hl_c*pi*lc*dc)/(rho_w*cp_w*qcsyms))));%s
fprintf("talsym: %s \n", char(tau_c_laminar))
tau_s_laminar(i) = (mcv*cp_al)/((rho_w*cp_w*qs(i))*(1-exp((-hl_s(i)*pi*ls*ds)/(rho_w*cp_w*qs(i)))));%s
fprintf("taunum: %f \n",tau_s_laminar(i))
qcsolution_lam(i) = vpasolve (tau_c_laminar == tau_s_laminar(i));
fprintf("vpasolve: %f \n",qcsolution_lam(i))
end
end
See Also
Categories
Find more on Equation Solving 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!