How do I plot a function with multiple steps

조회 수: 12 (최근 30일)
Alexander Garber
Alexander Garber 2021년 9월 23일
댓글: VBBV 2021년 9월 23일
Hello,
I am trying to plot a function, Re. This function requires a size, which I have called y. How can I plot Re, with the size of y changing. It gives me a straight line. Thanks for the help, I am very new to this.
syms y z a b c
x=10
viscosity=(1.8*10^-5)
Pi=3.1415926
Densityair=1.25
Densitypart=1000
for y=(.01*10^-9):(1*10^-2)
yint=(.01*10^-9)
y=yint+(1*10^-6)
Re=(Densityair*x*y)/viscosity
fplot(Re)
end

채택된 답변

VBBV
VBBV 2021년 9월 23일
syms y z a b c
x=10
viscosity=(1.8*10^-5)
Pi=3.1415926
Densityair=1.25
Densitypart=1000
y=(.01*10^-9):(0.01*10^-9+10^-6):(1*10^-2);
Re=(Densityair*x*y)/viscosity
plot(Re)
You can use simple plot function
  댓글 수: 2
Alexander Garber
Alexander Garber 2021년 9월 23일
That part works, thanks. Next, I need to use that function to define another function. It is now saying that the matrix definitions must agree. How should I fix this
syms y z a b c
x=10
viscosity=(1.8*10^-5)
Pi=3.1415926
Densityair=1.25
Densitypart=1000
y=(.01*10^-9):(0.01*10^-9+10^-6):(1*10^-2);
Re=(Densityair*x*y)/viscosity
Cd=piecewise(Re<.1, (24/Re), .1<Re<2, (24/Re)*(1+.1875*Re+.05625*Re*Re*ln(2*Re)), 2<Re<500, (24/Re)*(1+.15*Re^.687), Re>500, .44)
plot(Cd)
VBBV
VBBV 2021년 9월 23일
syms y z a b c
x=10
viscosity=(1.8*10^-5)
Pi=3.1415926
Densityair=1.25
Densitypart=1000
y=(.01*10^-9):(0.01*10^-9+10^-6):(1*10^-2);
Ree=(Densityair*x*y)/viscosity;
plot(Ree)
syms Re
Cd=piecewise(Re<.1,(24./Re),0.1<Re<2, (24./Re).*(1+0.1875*Re+0.05625*Re.*Re.*log(2*Re)), 2<Re<500, (24./Re).*(1+.15*Re.^0.687), Re>500, 0.44)
CdY = double(subs(Cd,Re,Ree));
You can use element wise operators in your expression

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

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by