Clear Filters
Clear Filters

graph the parametric surfaces

5 views (last 30 days)
Lee
Lee on 20 Mar 2024
Answered: Hassaan on 20 Mar 2024
How do create the graph for the parametric surfaces?
My codes as below but it can't run properly.
% Define the parametric surface function r(u,v)
r = @(u,v) [u.*v.^(-2); u.^(-2).*v; (u.^(-2) - v.^(-2))];
% Define the range of u and v
u = linspace(0.1, 2, 50); % Adjust the range and number of points as needed
v = linspace(0.1, 2, 50);
% Create a grid of (u,v) values
[U, V] = meshgrid(u, v);
% Evaluate the parametric surface function at each point on the grid
x = r(U, V);
% Plot the surface
surf(X, Y, Z, 'EdgeColor', 'none');
Unrecognized function or variable 'X'.
xlabel('x');
ylabel('y');
zlabel('z');
title('Parametric Surface: r(u,v) = (u*v^(-2))*i + (u^(-2)*v)*j + ((u^(-2) - v^(-2)))*k');
  1 Comment
Chuguang Pan
Chuguang Pan on 20 Mar 2024
You should use three different surface function , , . Instead of using just one function to repensent three components of vector fields.

Sign in to comment.

Answers (1)

Hassaan
Hassaan on 20 Mar 2024
% Define the parametric surface function r(u,v)
r = @(u,v) [u.*v, u.*v.^(-2); u.*v.^(-2), u.^(-2) - v.^(-2)];
% Define the range of u and v
u = linspace(0.1, 2, 50); % Adjust the range and number of points as needed
v = linspace(0.1, 2, 50);
% Create a grid of (u,v) values
[U, V] = meshgrid(u, v);
% Evaluate the parametric surface function at each point on the grid
% r is a function that returns a 2x2 matrix, but for plotting surfaces we need to evaluate three functions r_x, r_y, r_z for X, Y, Z coordinates.
R = r(U, V);
% Extract individual components for X, Y, Z coordinates
X = U .* V; % r_x component: u*v
Y = U .* V.^(-2); % r_y component: u*v^(-2)
Z = U.^(-2) - V.^(-2);% r_z component: u^(-2) - v^(-2)
% Plot the surface
surf(X, Y, Z, 'EdgeColor', 'none');
% Labeling the axes
xlabel('x');
ylabel('y');
zlabel('z');
title('Parametric Surface: r(u,v) = (uv)i + (u*v^(-2))j + (u^(-2) - v^(-2))k');
-----------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
It's important to note that the advice and code are based on limited information and meant for educational purposes. Users should verify and adapt the code to their specific needs, ensuring compatibility and adherence to ethical standards.
Professional Interests
  • Technical Services and Consulting
  • Embedded Systems | Firmware Developement | Simulations
  • Electrical and Electronics Engineering
Feel free to contact me.

Community Treasure Hunt

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

Start Hunting!