How to slice a 3D structure into a X-Y planar?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I get the error
''Error using slice (line 85)
V must be a 3-D array.
Error in HEX_hybridization (line 104)
slice(X,Y,Z,TO,xslice,yslice,zslice)''
How can I make TO=V a 3D array?
clc
clear
close all
% Define the space boundary of the TPMS in x,y,z, in terms of number of unit cells
Lx = 3;
Ly = 3;
Lz = 9;
% Define dimensions in centimeters
unitCellLength_mm = 10; % Length of the unit cell in millimeters
wallThickness_um = 100; % Wall thickness in micrometers
% Define mesh resolution (number of grid points per unit cell)
Nx = 5;
Ny = 5;
Nz = 5;
% Generate meshgrid for the entire structure
x = linspace(0, 3, Nx*3);
y = linspace(0, 3, Ny*3);
z = linspace(0, 9, Nz*9);
[X, Y, Z] = meshgrid(x, y, z);
% Define equations
EQ_gy = cos(2*pi*X).*sin(2*pi*Y) + cos(2*pi*Y).*sin(2*pi*Z) + cos(2*pi*Z).*sin(2*pi*X); %gyroid TPMS
sig = 1./(1+exp(4*x)); %sigmoid function
C1 = 1-sig;
C2 = 1-C1;
EQ_hyb = (sig.*EQ_pr+C1.*EQ_gy+C2.*EQ_dm); %PGD,
% Volume fraction and porosity
volumeFraction = 0.5;
porosity = 1 - volumeFraction;
% Threshold to obtain the desired volume fraction
threshold = (max(EQ_hyb(:)) - min(EQ_hyb(:))) * volumeFraction + min(EQ_hyb(:));
% Generate the TPMS structure
structure = EQ_hyb <= threshold;
% Isosurface and isocap
[F1,V1] = isosurface(X,Y,Z,structure,0.5);
[F2,V2] = isocaps(X,Y,Z,structure,0.5);
%Combines isosurface and isocaps into one
F3 = [F1;F2+length(V1(:,1))];
V3 = [V1;V2];
TO = triangulation(F3,V3(:,1),V3(:,2),V3(:,3));
trisurf(TO,'FaceColor','c','FaceAlpha',1,'EdgeAlpha',1,'EdgeColor','none');
%Slice the topology to view the grading/hybridization at unit cell level
xslice = [0.5,1.5,2.5];
yslice = [];
zslice = 0;
slice(X,Y,Z,TO,xslice,yslice,zslice)
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Volume Visualization dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!