Match matrix values with mesh nodes

4 visualizaciones (últimos 30 días)
Maksim
Maksim el 13 de Mayo de 2024
Respondida: Suraj Kumar el 6 de En. de 2025
I've obtained mesh on an image, and I have a color intensity matrix of the same image. Matrix values I want to multiply with Modulus of Elasticity value and then match them with the numbers of mesh nodes/elements according to their position, and import the result into ANSYS. The matrix and the mesh are attached below.
Mesh is obtained using im2mesh by JieXian Ma. It's represented as a n-by-2 array of nodes (x and y positions), m-by-3 array of triangles (positions of 3 nodes forming a triangle) and m-by-1 array of grayscale phases (phases are initially selected to generate a mesh according to an intensity of gray color)
As I understand, there should be a loop which:
  • checks the position of a mesh node (x and y)
  • checks the position of a value in the matrix (row and column)
  • assigns the value of a matrix to the node (a new array with these values)
Or does the same, but with an element instead of a node (with averaged coordinate between nodes)
But I may be wrong, as I'm new in Matlab
And I don't know how to make this loop properly, because the matrix is a square with many values equal to 0 (it initially was 255 and represented air, I just inversed the values so the air is represented as pure black color), while mesh is made differently and doesn't include empty region (which is air)
I hope I explained it well. If you don't understand something, please tell me
  1 comentario
Maksim
Maksim el 13 de Mayo de 2024
As I understand, maybe I can just reindex a matrix and remove zeros from it, but how to do it properly so it will match with the VERT array?

Iniciar sesión para comentar.

Respuestas (1)

Suraj Kumar
Suraj Kumar el 6 de En. de 2025
To map values from a color intensity matrix of an image to a mesh obtained from the same image, you can refer to the following steps:
1. Load the necessary data using the 'load' function in MATLAB. This will import the intensity matrix (gray_matrix), mesh nodes (nodes), and triangles (triangles).
2. Iterate over each node in the mesh to map intensity values from the matrix. Convert the node's (x, y) coordinates into matrix indices, retrieve the corresponding intensity value, and multiply it by the Modulus of Elasticity.
3. Prepare the mapped node or element values for export to ANSYS by writing them to a file in a suitable format, such as CSV, using 'csvwrite' function in MATLAB.
To learn more about the 'csvwrite' function in MATLAB, please refer to the following documentation:
Hope this helps!

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by