MATLAB Answers

why is my plot plotting blank?

조회 수: 1(최근 30일)
Rand Ardat
Rand Ardat 2020년 11월 25일
댓글: Jon 2020년 11월 25일
g = 9.8 %m/s^2
rohp = 1800 %kg/m3
Dp = 0.208*10^(-3); %m
T = 298.15 %K
roh = 994.6 %kg/m3
vis = 8.931*10.^-4 %kg/m · s
Vt=0:0.1:60
Re=roh*Vt*Dp/vis
Cd=zeros(1)
if Re>0.1 & Re<=1000
Cd= (24./Re).*(1+0.14*(Re.^0.7));
end
thvis=@(Vt) Vt-((4.*g.*(rohp-roh).*Dp)./(3.*Cd.*roh)).^(0.5)
dthvis=@(Vt) 1
y=thvis(Vt);
plot(Vt,y);

답변(3개)

Jon
Jon 2020년 11월 25일
The reason your plot is blank is because all of your y values are infinite. They are infinite because Cd is zero for all of your points and Cd is in the denominator of your calculation. Note that you initialize your Cd to zero, and then because you never satisfy the if statement on Reynolds number range it remains zero.
  댓글 수: 2
Jon
Jon 2020년 11월 25일
Actually you probably just want to work with values that are in the correct Re range you could do it like this
g = 9.8 %m/s^2
rohp = 1800 %kg/m3
Dp = 0.208*10^(-3); %m
T = 298.15 %K
roh = 994.6 %kg/m3
vis = 8.931*10.^-4 %kg/m · s
Vt=0:0.1:60
Re=roh*Vt*Dp/vis
% just keep values that are in Reynolds range
idx = Re>0.1&Re<1000;
Cd = (24./Re(idx)).*(1+0.14*(Re(idx).^0.7))
Vt = Vt(idx);
% calculate and plot function values
thvis=@(Vt) Vt-((4.*g.*(rohp-roh).*Dp)./(3.*Cd.*roh)).^(0.5)
y=thvis(Vt);
plot(Vt,y);

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


Star Strider
Star Strider 2020년 11월 25일
The value of ‘Cd’ is 0 in the code you posted, so ‘y’ is uniformly -Inf.

David Hill
David Hill 2020년 11월 25일
g = 9.8; %m/s^2
rohp = 1800;%kg/m3
Dp = 0.208e-3; %m
T = 298.15; %K
roh = 994.6; %kg/m3
vis = 8.931e-4; %kg/m · s
Vt=0:0.1:60;
Re=roh*Vt*Dp/vis;
Cd=zeros(size(Re));
Cd(Re>.1&Re<=1000)=(24./Re(Re>.1&Re<=1000)).*(1+0.14*(Re(Re>.1&Re<=1000).^0.7));
thvis=@(Vt) Vt-((4*g*(rohp-roh)*Dp)./(3*Cd*roh)).^(0.5);
y=thvis(Vt);
plot(Vt,y);

Community Treasure Hunt

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

Start Hunting!

Translated by