# How do I plot a function with multiple steps

3 views (last 30 days)
Alexander Garber on 23 Sep 2021
Commented: VBBV on 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

VBBV on 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 CommentsShowHide 1 older comment
VBBV on 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

R2021a

### Community Treasure Hunt

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

Start Hunting!