I cannot solve the vpasolve using a symbolic function. Symbolic equal to Inf

3 ビュー (過去 30 日間)
Lucas Teixeira
Lucas Teixeira 2020 年 5 月 2 日
コメント済み: Lucas Teixeira 2020 年 5 月 10 日
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));

回答 (1 件)

Guru Mohanty
Guru Mohanty 2020 年 5 月 7 日
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
  1 件のコメント
Lucas Teixeira
Lucas Teixeira 2020 年 5 月 10 日
Mohanty, Thanks so much for your time. Sorry for the undeclared variables I tried to take this part from the original script and I forgot to declare those variables before post it. Sorry again!
Yeah, you got my intention. It is working now...in the original script the problem the solution is that for the first element of the input vector the symbolic equation is Inf.
Anyway, thanks so much for your help.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeEquation Solving についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by