필터 지우기
필터 지우기

How to plot nodal displacement using mesh.m

조회 수: 12 (최근 30일)
Derek Cooper
Derek Cooper 2023년 2월 14일
답변: Kartik 2023년 2월 22일
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
Dyuman Joshi
Dyuman Joshi 2023년 2월 14일
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 2023년 2월 14일
The nodal displacements are one column for the displacement in each direction.

댓글을 달려면 로그인하십시오.

답변 (1개)

Kartik
Kartik 2023년 2월 22일
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.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by