# Math Help - MATLAB Hyperbolic Paraboloid

1. ## MATLAB Hyperbolic Paraboloid

Hi,

I am trying to create a hyperbolic paraboloid much like the one I have below, but instead of having a square region as shown, I would like to have an ellipse (to give an effect similar to the roof shape on the Calgary Olympic stadium).

My problem is that I have only used the "meshgrid" command in matlab to generate square/rectangular regions so I am unsure how to do this. I think I need to find an appropriate parametrization of an ellipse in order to produce the result I am after. I can see that if I wanted a circle I would use a parametrization of radius and the angle theta but for an ellipse where the radius is not constant I am pretty confused on how to achieve this.

Any help would be greatly appreciated,

Regards Elbarto

Code for images below

Code:
%Hyperbolic paraboloid
x = [-10:.5:10];
y=[-10:.5:10];
[X, Y] = meshgrid(x,y);
Z = X.^2-Y.^2;
surf(X,Y,Z)
xlabel x
ylabel y
zlabel z

2. Originally Posted by elbarto
Hi,

I am trying to create a hyperbolic paraboloid much like the one I have below, but instead of having a square region as shown, I would like to have an ellipse (to give an effect similar to the roof shape on the Calgary Olympic stadium).

My problem is that I have only used the "meshgrid" command in matlab to generate square/rectangular regions so I am unsure how to do this. I think I need to find an appropriate parametrization of an ellipse in order to produce the result I am after. I can see that if I wanted a circle I would use a parametrization of radius and the angle theta but for an ellipse where the radius is not constant I am pretty confused on how to achieve this.

Any help would be greatly appreciated,

Regards Elbarto

Code for images below

Code:
%Hyperbolic paraboloid
x = [-10:.5:10];
y=[-10:.5:10];
[X, Y] = meshgrid(x,y);
Z = X.^2-Y.^2;
surf(X,Y,Z)
xlabel x
ylabel y
zlabel z
I'm not sitting at a machine with Matlab at the moment so I don't know if M. works this way but:

Code:
dr=0.2;
r=dr/2:dr:10;
dtheta=2*pi/20;
theta=0:dtheta:dtheta*20;

x=kron(r,cos(theta));
y=kron(r,sin(theta));

[X, Y] = meshgrid(x,y);
Z = X.^2-Y.^2;
surf(X,Y,Z)
.

3. Thanks for the reply Constatine11.

Unfortunately the code you provided also produced a plot over a square domain. Does anyone know if MATLAB is even capable of plotting surfaces over a non square / rectangular domain?

4. ## Non rectangular domain in Matlab

%================================================= =========================
%"I am trying to create a hyperbolic paraboloid much like the one I have
% below, but instead of having a square region as shown, I would like to
% have an ellipse (to give an effect similar to the roof shape on the
% My problem is that I have only used the "meshgrid" command in matlab
% to generate square/rectangular regions so I am unsure how to do this.
% I think I need to find an appropriate parametrization of an ellipse
% in order to produce the result I am after. I can see that if I wanted
% a circle I would use a parametrization of radius and the angle theta
% but for an ellipse where the radius is not constant I am pretty confused
% on how to achieve this."
% Any help would be greatly appreciated,
%
% Regards Elbarto
%
% Prof. Diomar Cesar Lobao PhD.
% www.professores.uff.br/diomar_cesar_lobao
%================================================= =========================
%
clear all; clc; close all;
%
%Hyperbolic paraboloid
figure(1)
%
a = 2.0; % major axis
b = 1.0; % minor axis
x = [-10:0.015:10];
y=[-10:0.015:10];
[X, Y] = meshgrid(x,y);
Z = X.^2-Y.^2;
surf(X,Y,Z)
xlabel x
ylabel y
zlabel z
%
figure(2)
%
%
[I,J] = find((X.^2/a^2 + Y.^2/b^2) <= 1); % Trick here!!!
%
for k=1:size(I,1)
tmy(I(k),J(k))=X(I(k),J(k));
tmz(I(k),J(k))=Y(I(k),J(k));
tmu(I(k),J(k))=(tmy(I(k),J(k))^2 - tmz(I(k),J(k))^2);
end
end
%
%
surf(tmy,tmz,tmu);
%