How to plot nodal displacement using mesh.m

19 views (last 30 days)
Derek Cooper
Derek Cooper on 14 Feb 2023
Answered: Kartik on 22 Feb 2023
Dear all,
I have a matrix with 3 colums such that:
X = mat(:,1); Y = mat(:,2); Z = mat(:,3)
With X,Y,Z being coordinates. Now i want to input different values for Z and plot the nodal displacement. However, my nodal displacement does nto come as a matrix but as a vector.
Any ideas?
  2 Comments
Dyuman Joshi
Dyuman Joshi on 14 Feb 2023
How are you calculating the Nodal displacement? It's difficult to tell without any code or any context as to what you are trying to do.
Derek Cooper
Derek Cooper on 14 Feb 2023
The nodal displacements are one column for the displacement in each direction.

Sign in to comment.

Answers (1)

Kartik
Kartik on 22 Feb 2023
Hi,
Assuming that you have a vector of nodal displacements U that corresponds to the nodes in your mesh, you can use the mesh function in MATLAB to plot the nodal displacement. Here's an example code snippet that shows how to do this:
% Generate some example data
[X,Y] = meshgrid(0:0.5:5);
Z = sin(X) + cos(Y);
U = randn(size(Z));
% Create a mesh plot of the nodal displacements
mesh(X,Y,Z,U);
% Label the plot
xlabel('X');
ylabel('Y');
zlabel('Z');
title('Nodal Displacement');
% Add a colorbar to show the magnitude of the nodal displacement
colorbar;
In this code, the mesh function is used to create a 3D plot of the mesh with nodal displacements represented by the color of each node. The X, Y, and Z matrices represent the coordinates of each node in the mesh, and the U vector contains the nodal displacements. The colorbar function is used to add a colorbar to the plot, which shows the magnitude of the nodal displacement at each node.
You can modify this code to use your own data by replacing X, Y, Z, and U with your own matrices and vectors.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!