I understand that the goal is to plot a hyperbolic surface constrained within an elliptical region. This can be achieved by evaluating the hyperbola only where it satisfies the ellipse equation. The following are the steps to be followed:
- A 3D grid is created using “meshgrid” to evaluate the equations over a specified range.
[xGrid, yGrid, zGrid] = meshgrid(linspace(-25, 25, 50), linspace(-25, 25, 50), linspace(-20, 0, 50));
The following documentation link of “meshgrid” may be helpful:
2. A logical mask “ellipseMask” is calculated to determine which points lie inside the ellipse.
ellipseMask = ((xGrid-(E0-28))/Emajor).^2 + (zGrid/Eminor).^2;
3. The hyperbola equation is evaluated over the grid and the mask “ellipseMask” is applied.
hyperbolaValues = real(((xGrid-H0)./Hmajor(zGrid)).^2 - (yGrid./Hminor(zGrid)).^2);
4. The full hyperbolic surface is plotted using “isosurface”.
isosurface(xGrid, yGrid, zGrid, hyperbolaValues, 0);
You may refer to the documentation of “isosurface” to know how to use it:
5. The ellipse is plotted similarly as above.
isosurface(xGrid, yGrid, zGrid, ellipseMask, 1);
6. The hyperbolic surface within the ellipse is calculated as below:
ellipseMask = ellipseMask <= 1;
constrainedHyperbolaValues = hyperbolaValues;
constrainedHyperbolaValues(~ellipseMask) = NaN;
7. Finally, the hyperbolic surface calculated above is plotted using “isosurface”.
isosurface(xGrid, yGrid, zGrid, constrainedHyperbolaValues, 0);
Given below are the figures for the full hyperbolic surface (Fig 1), ellipse (Fig 2) and the hyperbolic surface within the ellipse (Fig 3) respectively:
Fig 1
Fig 2
Fig 3