Exporting image-generated geometry in matlab to FEA compatible format

2 ビュー (過去 30 日間)
Sebastián Fernández
Sebastián Fernández 2024 年 8 月 6 日
回答済み: Rahul 2024 年 8 月 7 日
  • Hello, I am doing an undergraduate thesis, and I like to implement MATLAB in some of the analysis.
  • The query is, how to export a file generated as an image in a code, to a format compatible with FEA (Finite element analysis).
  • The goal is to find the temperature profile in this slag pot geometry, which is a truncated cone.
  • So, once having the compatible geometry I can use matlab pdegplot and some commands related to find the temperature profile.
  • The code was generated by AI (Claude).
% Dibujo tronco de cono en 3D. Luego, obtener el perfil de temperatura y
% modelamiento de pérdida de calor mediante el uso de ecuaciones
% diferenciales.
% Parámetros del problema
R1 = 1.155; % Semi-eje mayor de la elipse menor (m)
R2 = 2.082; % Semi-eje mayor de la elipse mayor (m)
b1 = 1.549; % Semi-eje menor de la elipse mayor (m)
b2 = 0.838; % Semi-eje menor de la elipse menor (m)
h = 2.921; % Altura del tronco de cono (m)
theta = linspace(0, 2*pi, 100); % Ángulo para las elipses
% Coordenadas para la elipse menor (base inferior)
x1 = R1 * cos(theta);
y1 = b2 * sin(theta);
z1 = zeros(size(theta));
% Coordenadas para la elipse mayor (base superior)
x2 = R2 * cos(theta);
y2 = b1 * sin(theta);
z2 = h * ones(size(theta));
% Superficie lateral del tronco de cono
[Theta, Z] = meshgrid(theta, linspace(0, h, 100));
R = (R2 - R1) / h * Z + R1;
B = (b1 - b2) / h * Z + b2;
X = R .* cos(Theta);
Y = B .* sin(Theta);
% Graficar el tronco de cono
figure;
hold on;
surf(X, Y, Z, 'EdgeColor', 'none', 'FaceAlpha', 0.7); % Superficie lateral
fill3(x1, y1, z1, 'r'); % Base inferior
fill3(x2, y2, z2, 'b'); % Base superior
xlabel('X (m)');
ylabel('Y (m)');
zlabel('Z (m)');
title('Tronco de Cono con Bases Elípticas');
axis equal;
grid on;
hold off;
  1 件のコメント
dpb
dpb 2024 年 8 月 6 日
% Dibujo tronco de cono en 3D. Luego, obtener el perfil de temperatura y
% modelamiento de pérdida de calor mediante el uso de ecuaciones
% diferenciales.
% Parámetros del problema
R1 = 1.155; % Semi-eje mayor de la elipse menor (m)
R2 = 2.082; % Semi-eje mayor de la elipse mayor (m)
b1 = 1.549; % Semi-eje menor de la elipse mayor (m)
b2 = 0.838; % Semi-eje menor de la elipse menor (m)
h = 2.921; % Altura del tronco de cono (m)
theta = linspace(0, 2*pi, 100); % Ángulo para las elipses
% Coordenadas para la elipse menor (base inferior)
x1 = R1 * cos(theta);
y1 = b2 * sin(theta);
z1 = zeros(size(theta));
% Coordenadas para la elipse mayor (base superior)
x2 = R2 * cos(theta);
y2 = b1 * sin(theta);
z2 = h * ones(size(theta));
% Superficie lateral del tronco de cono
[Theta, Z] = meshgrid(theta, linspace(0, h, 100));
R = (R2 - R1) / h * Z + R1;
B = (b1 - b2) / h * Z + b2;
X = R .* cos(Theta);
Y = B .* sin(Theta);
% Graficar el tronco de cono
figure;
hold on;
surf(X, Y, Z, 'EdgeColor', 'none', 'FaceAlpha', 0.7); % Superficie lateral
fill3(x1, y1, z1, 'r'); % Base inferior
fill3(x2, y2, z2, 'b'); % Base superior
xlabel('X (m)');
ylabel('Y (m)');
zlabel('Z (m)');
title('Tronco de Cono con Bases Elípticas');
axis equal;
grid on;
hold off;
view([-37.5 30]) % lets look at a 3D view
ans = 'orthographic'
For FEA modeling, you need the mesh coordinates and connectivity. Is your intent to export to an external FEA code like Ansys for the computation or do it all in MATLAB? There's generateMesh in the PDE Toolbox and some examples

サインインしてコメントする。

回答 (1 件)

Rahul
Rahul 2024 年 8 月 7 日
According to my understanding you wish to export the values generated by your code to an format conmpatible with FEA.
From the code provided by you, you can consider exporting your values to an '.stl' file which is a common format for FEA.
In addition to the code provided by you, you can do the following steps:
% Convert surface data to patch data
[F, V] = surf2patch(X, Y, Z, 'triangles');
% Create a triangulation object
TR = triangulation(F, V);
% Write the triangulation data to an STL file
stlwrite(TR, 'truncated_cone.stl');
Here the 'surf2patch' function is used to convert the surface data (X, Y, Z) into a patch structure returning Faces(F) and Vectices(V) of the object.
The 'triangulation' function takes the Faces(F) and Vertices(V) and creates a traingulation object (TR) which can be used to define geometry of the obejcts.
The 'stlwrite' function takes the 'triangulation' object (TR) and writes it's geometrical structure in a '.stl' format.
You can refer to the following documentations to know more about these functions:
Hope this helps! Thanks.

カテゴリ

Help Center および File ExchangeGeneral PDEs についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by