Borrar filtros
Borrar filtros

Revolving a 2D profile around any axis

14 visualizaciones (últimos 30 días)
Stephen Purk
Stephen Purk el 23 de Mzo. de 2020
Comentada: Ayan el 26 de Jun. de 2024 a las 19:00
Hello, I'm trying to rotate a curve around the y - axis. The code is under:
figure
% Define our initial profile
t = 0:.01:1;
x = 2*pi*t + 1;
y = sin(2*pi*t) + 2;
plot(x,y);
figure
% We use the cylinder function to rotate and align
% with the z-axis, to produce a 3D solid
[X,Y,Z] = cylinder(y);
surf(X,Y,Z)
The problem is that the cylinder does not count the x coordinates from the 2D profile and only revolves the curve around the z - axis. Can anyone help?

Respuestas (1)

Devineni Aslesha
Devineni Aslesha el 26 de Mzo. de 2020
The rotate function allows you to rotate a curve around any axis. To rotate the curve along y-axis, use the below code.
h = surf(X,Y,Z);
for i = 1:360
rotate(h,[0 1 0], i);
drawnow;
end
For more information, refer the following link.
  1 comentario
Ayan
Ayan el 26 de Jun. de 2024 a las 19:00
Hello,
If you have this plot:
t = 0:.01:1;
x = 2*pi*t + 1;
y = sin(2*pi*t) + 2;
plot(x,y);
figure
and want to get a surface plot from an x-y plot, how would I approach this? Essentially if the x axis is goin from 0-1, then revolve the x axis around the y axis and generate a surface plot. How would I go about this?

Iniciar sesión para comentar.

Categorías

Más información sobre Polar Plots en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by