"Symbolic parameters not supported in nonpolynomial equations"

조회 수: 2 (최근 30일)
Maya Venugopalan
Maya Venugopalan 2020년 10월 7일
댓글: Maya Venugopalan 2020년 10월 8일
clc;
clear all;
close all;
syms a b d y c
x = 0.1; %leading egde distance (in cm)
Re = 1000; %Reynolds number
delta = (5*x)/(Re^(1/2)); %Boundary layer thickness
nu = 8.926e-03; %kinematic viscosity (in cm2./s)
U_inf = (Re*nu)/x; %freestream velocity(in cm./s)
alpha = 1:1:20; %wave number (in 1./cm)
U(y) = a*y^2 + b*y + d; %velocity profile equation
DU(y) = diff(U(y),y);
eqn1 = U(0)==0; %boundary condition1
eqn2 = U(delta)==U_inf; %boundary condition2
eqn3 = DU(delta)==0; %boundary condition3
eqns = [eqn1 eqn2 eqn3];
soln = solve(eqns,a,b,d);
a = double(soln.a); %value of a in velocity profile (in 1./cm.s)
b = double(soln.b); %value of b in velocity profile (in 1./s)
d = double(soln.d); %value of d in velocity profile (in cm./s)
z = delta./2; %location of y
u = double(subs(a*z^2 + b*z + d));
ddu = double(2*a);
%Non-dimensionalizing
Uy = double(u./U_inf);
ddUy = double((ddu.*delta.^2)./U_inf);
A = double(alpha.*delta);
Y = z./delta;
%Roots of the OS equation
C = zeros(1,length(alpha));
for i=1:1:20
l1(i) = -((-((A(i).*Re.*c.*1i)-(2.*A(i).^2)-(A(i).*Re.*Uy.*1i))+((2.*A(i).^2.*Re.^2.*Uy.*c)-(A(i).^2.*Re.^2.*(Uy.^2+c.^2))-(4.*A(i).*Re.*ddUy.*1i)).^(1/2))/2).^(1./2);
l2(i) = -((-((A(i).*Re.*c.*1i)-(2.*A(i).^2)-(A(i).*Re.*Uy.*1i))-((2.*A(i).^2.*Re.^2.*Uy.*c)-(A(i).^2.*Re.^2.*(Uy.^2+c.^2))-(4.*A(i).*Re.*ddUy.*1i)).^(1/2))/2).^(1/2);
LHS = ((Uy-c).*((l1(i).^2.*exp(l1(i).*y) - l2(i).^2.*exp(l2(i).*y)) - (a(i).^2.*(exp(l1(i).*y)-exp(l2(i).*y))))-(ddUy.*(exp(l1(i).*y)-exp(l2(i).*y))));
RHS = ((1/(a(i).*Re.*1i)).*(((l1(i).^4.*exp(l1(i).*y))-(l2(i).^4.*exp(l2(i).*y)))-(2.*a(i).^2.*(l1(i).^2.*exp(l1(i).*y) - l2(i).^2.*exp(l2(i).*y))) + a(i).^4.*(exp(l1(i).*y)-exp(l2(i).*y))));
eqn(i) = LHS-RHS;
C(i) = vpasolve(simplify(eqn(i)),c);
end
disp(C)
There is error inside the for loop. Can somebody help?
Thanks!!

답변 (1개)

Walter Roberson
Walter Roberson 2020년 10월 7일
C(i) = vpasolve(simplify(eqn(i)),c);
At that point in the code the equation involves more variables than just c, so you have more variables than equations.
vpasolve can handle more variables than equations only for polynomials, in which case it does the equivalent of solve() followed by vpa(), returning roots that involve the other variables.
  댓글 수: 2
Maya Venugopalan
Maya Venugopalan 2020년 10월 8일
So what should I do? I'm getting "Symbolic parameters not supported in nonpolynomial equations." again.
Maya Venugopalan
Maya Venugopalan 2020년 10월 8일
When I tried to separate the for loop, I got the answer. But that too different values of c using different programs.
clc;
clear all;
close all;
syms c
delta = 0.0158;
alp = 1:1:20;
a = alp.*delta;
Re = 1000;
y = 0.5;
y1 = y.*delta;
U = (-357554.879.*y1.^2 + 11298.734.*y1)./89.26;
ddU = -2;
C = zeros(1,length(alp));
for i=1:1:20
l3(i) = -((-((a(i).*Re.*c.*1i)-(2.*a(i).^2)-(a(i).*Re.*U.*1i))+((2.*a(i).^2.*Re.^2.*U.*c)-(a(i).^2.*Re.^2.*(U.^2+c.^2))-(4.*a(i).*Re.*ddU.*1i)).^(1./2))./2).^(1./2);
l4(i) = -((-((a(i).*Re.*c.*1i)-(2.*a(i).^2)-(a(i).*Re.*U.*1i))-((2.*a(i).^2.*Re.^2.*U.*c)-(a(i).^2.*Re.^2.*(U.^2+c.^2))-(4.*a(i).*Re.*ddU.*1i)).^(1./2))./2).^(1./2);
LHS = ((U-c).*((l3(i).^2.*exp(l3(i).*y) - l4(i).^2.*exp(l4(i).*y)) - (a(i).^2.*(exp(l3(i).*y)-exp(l4(i).*y))))-(ddU.*(exp(l3(i).*y)-exp(l4(i).*y))));
RHS = ((1./(a(i).*Re.*1i)).*(((l3(i).^4.*exp(l3(i).*y))-(l4(i).^4.*exp(l4(i).*y)))-(2.*a(i).^2.*(l3(i).^2.*exp(l3(i).*y) - l4(i).^2.*exp(l4(i).*y))) + a(i).^4.*(exp(l3(i).*y)-exp(l4(i).*y))));
eqn(i) = LHS-RHS;
C(i) = vpasolve(simplify(eqn(i)),c);
end
disp(C)
This gives me solutions properly. But not as same values as the first code though. Why is that so?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by