# How can I make a 3d plot with two equations and one variable?

1 view (last 30 days)
Christopher DSpain on 22 Mar 2023
Edited: John D'Errico on 22 Mar 2023
I am relatively new to matlab and I am trying to make a 3d plot using two functions, Q and W which both rely on the variable eta. I want to plot these functions in the range 0.6<eta<0.95.
syms v f eta;
f=0.0405;
eqnvel = (9.801-3.802.*v).*v.*eta==(((f.*200*(pi/4)*0.1^2)/6.434)+((27*(pi/4)*0.1^2)/64.34)).*v.^3;
[v]=solve(eqnvel,v);
vfun = matlabFunction(v(2));
Q=@(eta) (pi/4)*(0.1)^2.*vfun(eta);
hp=@(eta) 200-988.*Q;
W=@(eta) 62.4.*Q.*hp;
When I try fsurf or surf, I keep getting errors. Any help with this would be greatly appreciated

John D'Errico on 22 Mar 2023
Edited: John D'Errico on 22 Mar 2023
By the way, there is NO reason to define f as symbolic, and then assign the number 0.0405 to f. f is now double preicsion.
syms f
f = 0.0405;
whos f
Name Size Bytes Class Attributes f 1x1 8 double
f is a double. NOT symbolic.
As far as your question goes, did we just not do the same question?
Of course you get errors using surf. You have ONE unknown variable, eta. When you do the solve, you find v, as a function of eta.
Essentially, you can plot the results as a function of the one variable eta.
syms v eta;
f=0.0405;
eqnvel = (9.801-3.802.*v).*v.*eta==(((f.*200*(pi/4)*0.1^2)/6.434)+((27*(pi/4)*0.1^2)/64.34)).*v.^3;
[v]=solve(eqnvel,v);
vfun = matlabFunction(v(2))
vfun = function_handle with value:
@(eta)((eta.*1.901e+3-sqrt((eta.*(eta.*1.1625597817e+10+pi.*1.323135e+8))./8.0425e+8).*5.0e+2).*(-2.382962962962963e-1))./pi
So vfun is a function PURELY of eta. ONE variable. You can plot it as such.
fplot(vfun) Next, you define A,hp, W.
Still they are functions ONLY of eta. There is no surface implied. ONE independent variable only. Feel free to plot them, as also simple functions of eta. However, you need to define them properly, else you will find errors, and that will be your next question.
Q=@(eta) (pi/4)*(0.1)^2.*vfun(eta);
hp=@(eta) 200-988.*Q(eta);
W=@(eta) 62.4.*Q(eta).*hp(eta);
Do you see the change I made to hp and W?
fplot(Q) fplot(hp) fplot(W) A surface is a TWO dimensional manifold. A function of TWO independent variables. But you have only one variable here. And so NO surface.
Now, perhaps that you want to do, is to plot a parametric curve in several dimensions? For example, given two functions of a variable, we can use fplot.
F1 = @(t) cos(2*t);
F2 = @(t) sin(t).*cos(t);
fplot(F1,F2,[0,4*pi])
axis equal Given 3 functions, we can plot a parametric curve in 3-dimensions. This one should be an elliptical spiral, but one where the pitch of the helix varies.
F3 = @(t) t.^2;
fplot3(F1,F2,F3,[0,6*pi]) Again, still no surface exists.
Christopher DSpain on 22 Mar 2023
All I know is that my professor asked this of me: Determine and PLOT in 3D, volume flow rate (Q), as the pump efficiency varies from 60% to 95% vs. pump work (W) required to overcome viscous pressure drops.

### Categories

Find more on Surface and Mesh Plots in Help Center and File Exchange

R2021b

### Community Treasure Hunt

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

Start Hunting!