Author Topic: Parametric equations surface graph  (Read 1836 times)

Offline TheDestroyer

  • Newbie
  • *
  • Posts: 1
  • Matlab Forum
    • View Profile
Parametric equations surface graph
« on: December 09, 2009, 12:17:32 PM »
Hello people,

I'm trying to graph the traditional sphere equation or let's say in more general a 3D ellipse. The problem is that I'm failing to graph it using the function "surf", here's the script I'm using:

function SurfaceGraph(a,b,c,N,M)
t=(0:N)*2*pi/N;
u=(0:M)*pi/M;
    x=a*cos(t).*sin(u);
    y=b*sin(t).*sin(u);
    z=c*ones(N+1).*cos(u);
      surf(x,y,z);
end

and I'm calling the function: SurfaceGraph(1,1,1,100,100), the error I'm getting is about the matrices dimensionality.

I'm aware that the function "sphere" is there, that I can use for graphing spheres, but actually my purpose of this script is visualising different polyhedra through different discretisation of the angles t and u.

Please tell me how I can graph these parametric equations, any effort is appreciated.

Thanks

Matlab and SimuLink Development Forum

Parametric equations surface graph
« on: December 09, 2009, 12:17:32 PM »