why does matlab give me a message that a never-used varible is undefined?

1 view (last 30 days)
The first part is the main M file, the second part is a function M file. When it is run, a message "Undefined function or method 'le' for input arguments of type 'sym' ". But the variable le is never used in the code. I don't know why. I will appreciate if anyone can help.
MeanShearstress=5 ; %unit Pa
Density=1e3;
Ustar=sqrt(MeanShearstress/Density);
KinematicViscosity=1.004e-6;
D50=60e-6;
Roughness=2*D50;
RoughnessRenolds=Ustar*Roughness/KinematicViscosity;
CoefficientC=-0.993*log(RoughnessRenolds)+12.36;
Di=60e-6;
Protrusion=20e-6;
[MeanBedVelocity,Yb,Cd, Cl]=ProtrusionAssembly(Protrusion,Ustar,CoefficientC,D50,Di,KinematicViscosity);
function [MeanBedVelocity,Yb,Cd, Cl]=ProtrusionAssembly(Protrusion,Ustar,CoefficientC,D50,Di,KinematicViscosity)
Thickness=1.5*D50;
Y1=0.25*Thickness;
Y2=0.25*Thickness+Protrusion;
syms y;
Kapa=0.4;
MeanBedVelocity=(int((Ustar*CoefficientC*y/Thickness)*sqrt((0.5*Di)^2-(y-Protrusion-Y1+0.5*Di)^2),y,Y1,Thickness)...
+int((Ustar*(CoefficientC+log(y/Thickness)/Kapa))*sqrt((0.5*Di)^2-(y-Protrusion-Y1+0.5*Di)^2),y,Thickness,Y2))/(int(sqrt((0.5*Di)^2-(y-Protrusion-Y1+0.5*Di)^2),y,Y1,Y2));
if MeanBedVelocity<=Ustar*CoefficientC
Yb=(MeanBedVelocity*Thickness)/(Ustar*CoefficientC);
else
Yb=Thickness*exp(Kapa*(MeanBedVelocity/Ustar-CoefficientC));
end;
ParticleRenolds=MeanBedVelocity*Protrusion/KinematicViscosity;
if ParticleRenolds<=1754
Cd=(24/ParticleRenolds)*(1+0.15*ParticleRenolds^0.687);
else
Cd=0.36;
end;
if ParticleRenolds<8000
Cl=Cd;
end;

Accepted Answer

Walter Roberson
Walter Roberson on 6 Oct 2011
'le' is the printable name of the function <=
You are computing a result symbolically and attempting to compare the result using <= to some other value.
If you are sure that the symbolic result is a symbolic number with no remaining symbolic variables, then use double() to convert the symbolic result to a double precision number so it can be compared. This will, however, not work if there are any symbolic variables remaining in the expression.
  1 Comment
Lin LI
Lin LI on 6 Oct 2011
thank you so much,Walter, I convert the symbolic result MeanBedVelocity to double,now "the undefined variable or method" message disappeared, but when i run the code, it doesnt give me any result, like a deap loop, why is that? below are the function code I changed,while the main M code stays the same. should I avoid use symbolic integration? Instead using numerical integration is better?thank you so much!
Thickness=1.5*D50;
Y1=0.25*Thickness;
Y2=0.25*Thickness+Protrusion;
syms y;
Kapa=0.4;
MeanBedVelocity=(int((Ustar*CoefficientC*y/Thickness)*sqrt((0.5*Di)^2-(y-Protrusion-Y1+0.5*Di)^2),y,Y1,Thickness)...
+int((Ustar*(CoefficientC+log(y/Thickness)/Kapa))*sqrt((0.5*Di)^2-(y-Protrusion-Y1+0.5*Di)^2),y,Thickness,Y2))/(int(sqrt((0.5*Di)^2-(y-Protrusion-Y1+0.5*Di)^2),y,Y1,Y2));
% function Yb=AppPosi(MeanBedVelocity)
if double(MeanBedVelocity)<=Ustar*CoefficientC
Yb=(double(MeanBedVelocity)*Thickness)/(Ustar*CoefficientC);
else
Yb=Thickness*exp(Kapa*(double(MeanBedVelocity)/Ustar-CoefficientC));
end;
ParticleRenolds=double(MeanBedVelocity)*Protrusion/KinematicViscosity;
if ParticleRenolds<=1754
Cd=(24/ParticleRenolds)*(1+0.15*ParticleRenolds^0.687);
else
Cd=0.36;
end;
if ParticleRenolds<8000
Cl=Cd;
end;

Sign in to comment.

More Answers (1)

Lin LI
Lin LI on 6 Oct 2011
I have changed the int to quad, so that the computing velocity increased a lot . I have solved this problem ,thank you !

Community Treasure Hunt

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

Start Hunting!