How can I make a 3d plot with two equations and one variable?
1 view (last 30 days)
Show older comments
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
0 Comments
Answers (1)
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
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))
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.
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!