How to reshape 'Z' matrix for surf(X,Y,Z)

12 views (last 30 days)
Ashish Srivastava
Ashish Srivastava on 11 Jul 2023
Commented: Stephen23 on 11 Jul 2023
Hi. I am fairly new to MATLAB and I am trying to use surf to plot 3D surface plot for my modal curvature. i have meshed the grid and my X and Y matrices are of size 2000X2000. I want to reshape my 'Z' Matrix so that it becomes of size 2000X2000 from 2000X4.
Where 2000 is the number of elements in my beam and 4 is the vertices of those elements
Edit-Thank you guys for response but i have tried reshape(Z,2000,2000) before asking here. It is not working. Also I am using AEM based modelling so there are no nodes but the springs used for elements connections.
  1 Comment
Stephen23
Stephen23 on 11 Jul 2023
"Where 2000 is the number of elements in my beam and 4 is the vertices of those elements"
That sounds like you should use PATCH, rather than MESH:

Sign in to comment.

Answers (1)

Divyam
Divyam on 11 Jul 2023
You can use the reshape function.
updatedZ = reshape(Z', 2000, 2000);
More information about the reshape function: Reshape array - MATLAB reshape - MathWorks India
  1 Comment
Stephen23
Stephen23 on 11 Jul 2023
"You can use the reshape function."
No, you cannot use RESHAPE to change an array with 8000 elements into an array with 4000000 elements.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!