How to plot nodal displacement using mesh.m
17 views (last 30 days)
Show older comments
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
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.
Answers (1)
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.
0 Comments
See Also
Categories
Find more on Surrogate Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!