function ParametricSurface(u_min, u_max, N_u, v_min, v_max, N_v,... XString,YString,ZString) % % ParametricSurface(u_min, u_max, N_u, v_min, v_max, N_v,... % XString,YString,ZString) % % Plots the graph of a parametric surface % x=X(u,v), y=Y(u,v), z=Z(u,v) % where the paremeters (u,v) are in the range % u_min <= u <= u_max, v_min <= v <= v_max, with N_u grid points % in the u-direction and N_v grid points in the v-direction. % The functions X,Y,Z are specified by the strings XString, YString, ZString. % NOTE: All three string must contain BOTH u and v variables!! % If X = 3v you would enter XString = '0*u + 3*v' % % Typical call: % % ParametricSurface(-1,1,10,-1,1,10,'1+0*u+3*v','2-3*u + 0*v','1-2*u-5*v' ) u = linspace(u_min,u_max,N_u); v = linspace(v_min,v_max,N_v); [U,V] = meshgrid(u,v); XFunction = inline(XString); YFunction = inline(YString); ZFunction = inline(ZString); X = 0.*U + XFunction(U,V); Y = 0.*U + YFunction(U,V); Z = 0.*U + ZFunction(U,V); C = ones(size(X)); surf(X,Y,Z,C,'linewidth',2) % This gets the handle for the current axis hax=gca; % This sets the font name and size for all the text on the plot, including % tick labels and axis labels. set(hax,'fontname','helvetica','fontweight','bold','fontsize',20); xlabel('x') ylabel('y') zlabel('z') colormap('hsv') axis tight