How do I plot a function with multiple steps

12 vues (au cours des 30 derniers jours)
Alexander Garber
Alexander Garber le 23 Sep 2021
Commenté : VBBV le 23 Sep 2021
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

Réponse acceptée

VBBV
VBBV le 23 Sep 2021
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 commentaires
Alexander Garber
Alexander Garber le 23 Sep 2021
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 le 23 Sep 2021
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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Function Creation dans Help Center et File Exchange

Tags

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by