Plotting the solutions of an equation (rotated ellipsoid)

6 views (last 30 days)
Here is the equaion
one equation with three unknowns, so we need to give two variables to get the third one. Here is what I have done to solve the equation and plot the solutions:
Eqn = 4*x^2 - (y - 1/3)*((3*3^(1/2)*(z - 1/6))/16 - (13*y)/16 + 13/48) - (z - 1/6)*((3*3^(1/2)*(y - 1/3))/16 - (7*z)/16 + 7/96) == 1;
S = solve(Eqn, [z, x, y], 'ReturnConditions', true);
Av1 = -.6; Bv1 = .6; Nv1=15; Av2 = -1; Bv2 = 2; Nv2=20;
[iv1, iv2] = meshgrid(linspace(Av1, Bv1, Nv1), linspace(Av2, Bv2, Nv2));
iv1 = iv1(:);
iv2 = iv2(:);
v1 = zeros(2,1); v2 = zeros(2,1); v3 = zeros(2,1);
sv1 = zeros(2,1); sv2 = zeros(2,1); sv3 = zeros(2,1);
counter = 1;
for i = 1: length(iv1)
Zv = subs(S.zv, S.parameters, [iv2(i), iv1(i)]);
if isreal(Zv(1))
v1(counter) = iv1(i);
v2(counter) = iv2(i);
v3(counter) = max(Zv);
sv1(counter) = iv1(i);
sv2(counter) = iv2(i);
sv3(counter) = min(Zv);
counter = counter +1;
V = [v1, v2, v3]; %these are the points on the upper part of rotated ellipsiod
sV = [sv1, sv2, sv3]; %these are the points on the upper part of rotated ellipsiod
v1lin = linspace( min(v1), max(v1), 100);
v2lin = linspace(min(v2), max(v2), 100);
[Xv, Yv] = meshgrid(v1lin, v2lin);
Zv = griddata(v1,v2,v3,Xv,Yv, 'cubic');
sv1lin = linspace( min(sv1), max(sv1), 100);
sv2lin = linspace(min(sv2), max(sv2), 100);
[sXv, sYv] = meshgrid(sv1lin, sv2lin);
sZv = griddata(sv1,sv2,sv3,sXv,sYv, 'cubic');
mesh(Xv, Yv, Zv)
hold on
axis tight
mesh(sXv, sYv, sZv)
title('The complete surface by using Griddata interpolate on V vectors')
mesh(Xv, Yv, Zv)
hold on
axis tight
title('The half surface by using Griddata interpolate on V vectors')
As the obtained solutions are not uniformly distributed, I have used the griddata() to generate some uniformly spaced points to be able to plot the desired surface. However, the problem is that I cannot get to the complete rotated ellipsoid. Please see the attached photos. The blue points are the points which have been obtained by solving the equation. From mathematics, I know that the equation above is a rotated ellipsoid, but I cannot get there and always there is some part missing.
Is there any idea on how I can find some more points on the ellipsoid by solving the equation (or using some other techniques) which help me to plot the entire ellipsoid?
I should say that I have asked this question in another way here. However, as it has not received any notable attention, I tried to ask my question in a new way here.
Any help would be appreciated.

Answers (1)

Matt J
Matt J on 21 Sep 2021
Edited: Matt J on 21 Sep 2021
If you have the center, radii, and yaw-pitch-roll angles (in degrees) of the ellipsoid, you can plot a data-free ellipsoidalFit object using,
The final section in the Examples tab at this link gives examples of this, but basically it is,
Majid on 23 Sep 2021
Edited: Majid on 23 Sep 2021
Thank you Matt for your explanations! As always, very helpful! I could not find out the yaw-pitch-roll angles. Actually, my main aim is not to plot the solutions of the above equation, but it is to plot the solutions of a system of differential equations in which the solutions of the above equation are used as initial conditions. However, as for a special case, the solutions of the system and the equation were the same, so I asked the question here in this way.
Anyway, your reply to my comment in another thread worked very well and saved me! Thank you so much!!!
If it is possible, I would like to know what your field of research is.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!