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 Center および File ExchangeFunction Creation についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by