MATLAB Answers


How to plot a 51*51*51 array

Asked by desah
on 23 Nov 2012
Latest activity Answered by Michael scheinfeild on 9 Jul 2014

Hi, i'm a newbie of this community.I'm sorry for any next mistakes.For my thesis of dinamical of the structrures at university i have to calculate the pressure into an acustic hole.Here is the scripts for the calcus of this pressure in every point of the hole.the hole is a box with this dimensions(pi,2,1).i divided it into a grid of 51x51x51 points.

n_nod=51; %%%number of nodes for each side x=linspace(0,pi,n_nod); y=linspace(0,2,n_nod); z=linspace(0,1,n_nod);



for i=1:1:n_nod for j=1:1:n_nod for h=1:1:n_nod


the script generate an array Ppr of 51x51x51 elements.I'd like to plot Ppr in a 3D graph in different colour in fuction of the each points. which command can add to the script to do this??? thanks to all for any answer!


use mesh

on 23 Nov 2012

i don't know how use mesh.I've tried to add it in this way mesh(Ppr(:,:,1),Ppr(:,:,2),Ppr(:,:,3)) but the program returns just a multicolour line in a 3D-space.if i add the same command inside the for loop it never stop the loop.




No products are associated with this question.

3 Answers

Answer by Azzi Abdelmalek
on 23 Nov 2012
Edited by Azzi Abdelmalek
on 23 Nov 2012



Answer by desah
on 23 Nov 2012
Edited by desah
on 23 Nov 2012

thank you for the fast answer.I've tried to add mesh(Ppr(:,:,1),Ppr(:,:,2),Ppr(:,:,3)) after the for loop but it plots only the last values on a 3D space and it appears like a multicolour line.if i add the string into the for loop it never stops and goes in overclock.I just want to visualize a volume 51x51x51 points in differt it possible or not? Regard


on 23 Nov 2012

no i'm doesn't work.Out of the loop it write just a line.not a volume.if i put it into the loop it never stop

I can't tell what do you want to plot? Can you precize what do you want to plot, what are x, y and z

on 24 Nov 2012

x,y,z are 3 vectors of 51 points that form a grid box.(x,y,z=linspace(:,:.51)).I want to plot the matrix P that is function of x,y,z together.(I've calculated P in all the points of the space;you can verify this if you run my script,)In this way P is an array of 51*51*51 elements.I'd like to visualize a cube of different colours that represent the trend of the pressure inside the box in all points.

Answer by Michael scheinfeild on 9 Jul 2014

i think you need to look at volume visualization functions like figure,slice(Ppr,x,y,z)


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!