2D Matrix revolution

Hi community
How can I revolutionize a 2D matrix around an axis to obtain a solid?
Supose a NxN matrix. In each row are the points of a kind of gaussian curve with less amplitude and higher width. Plotting this surface shows something like a half bell that decays to zero. (See Bottom)
I want to obtain a 3D image revolutionazing that matrix, so the solid looks like a complete bell, or a mexican hat.
Notice that each curve in the matrix rows are different.
I have already try with cylinder(), but i can't define the rotation axis, and the result is a segmented solid.
Possible solutions so I can get the 3D image and define the rotation axis?
Thanks a lot
The surface to revolutioniye looks like this:
untitled.jpg
Cylinder shows this:
untitled.jpg

2 comentarios

darova
darova el 18 de Nov. de 2019
Which axis do you want to rotate?
Felipe Bayona
Felipe Bayona el 18 de Nov. de 2019
I would like to know the general method, where i can specify the axis. In this particular example, I need to do it around the z-axis, to obtain the 'Mexican hat'

Iniciar sesión para comentar.

Respuestas (2)

darova
darova el 18 de Nov. de 2019

1 voto

Use cylinder for each curve separately:
z = linspace(-1,1,20); % axis
r = sqrt(1-z.^2); % radius
[x,y,~] = cylinder(r,length(z)-1); % convert to cylinder system
zz = repmat(z',[1 20]); % create 2D matrix for Z matrix
surf(x,y,zz) % sphere

4 comentarios

Felipe Bayona
Felipe Bayona el 18 de Nov. de 2019
And how should it be?
in this case r is a 1x20 array, and its plotted with the x and y resuls of cylinder.
How it must be for each curve separately? (for example 10 or 100 r's of 1x20)
darova
darova el 18 de Nov. de 2019
attach the data
darova
darova el 18 de Nov. de 2019
And what is the problem?
x = linspace(0,40,41);
[X,T, rc] = normalDiffusion(4, 1, 1, x, 20);
z = X(i,:); % axis
r = rc(i,:); % radius
[x,y,~] = cylinder(r,length(z)-1); % convert to cylinder system
zz = repmat(z',[1 length(r)]); % create 2D matrix for Z matrix
surf(x,y,zz) % sphere
darova
darova el 19 de Nov. de 2019
Maybe z and r should be switched?
z = X(i,:); % axis
r = rc(i,:); % radius

Iniciar sesión para comentar.

Philippe Lebel
Philippe Lebel el 18 de Nov. de 2019

0 votos

1 comentario

Felipe Bayona
Felipe Bayona el 18 de Nov. de 2019
This only alows to rotate a y=f(x) funtion
My matrix is composed by many curves, because my function is z=f(x,y)

Iniciar sesión para comentar.

Categorías

Productos

Preguntada:

el 18 de Nov. de 2019

Comentada:

el 19 de Nov. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by