Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi could take a quick look at my MATLAB codes to see whether they are pre-initialized for large array? 1 function MapStructure(StrVol Mesh, OriCell) %

Hi could take a quick look at my MATLAB codes to see whether they are pre-initialized for large array?

image text in transcribed

image text in transcribed

1 function MapStructure(StrVol Mesh, OriCell) % Iso parametric mapping cell by cell 2 3 4 % Number of cells in a macro structure NumCells = length(StrVol Mesh. Elem(:,1)); 5 - 6 7 % STL information initialization f_write = zeros(NumCells+length(OriCell. faces), 12); 8 - 9 10 % Mapping unit cell figure(2); axis equal; grid on; for i = 1:1: NumCells BrickCoord = Str Vol Mesh.Node(StrVol Mesh. Elem(i, :), :); TransCell = Map Unit Cell(OriCell, BrickCoord); for = 1:1: length(TransCell. faces) ind TransCell. facesi, :); xlocal = TransCell.vertices( ind, 1); ylocal = TransCell.vertices(ind, 2); zlocal = TransCell.vertices(ind, 3); n_x = (ylocal(1) - ylocal(3)) + (zlocal(2) - zlocal(3)) - (zlocal(1) - zlocal(3)) + (ylocal(2) - ylocal(3)); n_y = (zlocal(1) - zlocal(3)) + (xlocal(2) - xlocal(3)) (zlocal(2) - zlocal(3)) (xlocal(1) - xlocal(3)); n_z = (xlocal(1) - xlocal(3)) + (ylocal(2) - ylocal(3)) (xlocal(2) - xlocal(3)) (ylocal(1) - ylocal(3)); - 11 12 - 13 14 - 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 - - f_writelj + (i-1)+length(OriCell. faces), :) = ... (n_x n_y n_z... xlocal(1) ylocal(1) zlocal(1)... xlocal(2) ylocal(2) zlocal(2)... xlocal(3) ylocal(3) zlocal(3)]; end 34 end 35 camlight; lighting flat; 36 end end camlight; lighting flat; % Create STL FILE ftitle = 'anti-reduced.stl'; fid = fopen(ftitle, 'w'); 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 - 48 49 - 50 51 52 53 54 55 56 57 58 59 1 _ %create binary stl file for i = (length(title)+1):80 ftitle(i) = ''; end fwrite(fid,ftitle, 'char+1'); fnumber = length(OriCell faces) +NumCells; fwrite(tid, fnumber, 'int32'); for i = 1:fnumber for j = 1:12 fwrite(fid, f_write(i, j),'float32'); end fwrite(tid, 0, 'int 16'); end fclose(fid); - 1 function MapStructure(StrVol Mesh, OriCell) % Iso parametric mapping cell by cell 2 3 4 % Number of cells in a macro structure NumCells = length(StrVol Mesh. Elem(:,1)); 5 - 6 7 % STL information initialization f_write = zeros(NumCells+length(OriCell. faces), 12); 8 - 9 10 % Mapping unit cell figure(2); axis equal; grid on; for i = 1:1: NumCells BrickCoord = Str Vol Mesh.Node(StrVol Mesh. Elem(i, :), :); TransCell = Map Unit Cell(OriCell, BrickCoord); for = 1:1: length(TransCell. faces) ind TransCell. facesi, :); xlocal = TransCell.vertices( ind, 1); ylocal = TransCell.vertices(ind, 2); zlocal = TransCell.vertices(ind, 3); n_x = (ylocal(1) - ylocal(3)) + (zlocal(2) - zlocal(3)) - (zlocal(1) - zlocal(3)) + (ylocal(2) - ylocal(3)); n_y = (zlocal(1) - zlocal(3)) + (xlocal(2) - xlocal(3)) (zlocal(2) - zlocal(3)) (xlocal(1) - xlocal(3)); n_z = (xlocal(1) - xlocal(3)) + (ylocal(2) - ylocal(3)) (xlocal(2) - xlocal(3)) (ylocal(1) - ylocal(3)); - 11 12 - 13 14 - 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 - - f_writelj + (i-1)+length(OriCell. faces), :) = ... (n_x n_y n_z... xlocal(1) ylocal(1) zlocal(1)... xlocal(2) ylocal(2) zlocal(2)... xlocal(3) ylocal(3) zlocal(3)]; end 34 end 35 camlight; lighting flat; 36 end end camlight; lighting flat; % Create STL FILE ftitle = 'anti-reduced.stl'; fid = fopen(ftitle, 'w'); 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 - 48 49 - 50 51 52 53 54 55 56 57 58 59 1 _ %create binary stl file for i = (length(title)+1):80 ftitle(i) = ''; end fwrite(fid,ftitle, 'char+1'); fnumber = length(OriCell faces) +NumCells; fwrite(tid, fnumber, 'int32'); for i = 1:fnumber for j = 1:12 fwrite(fid, f_write(i, j),'float32'); end fwrite(tid, 0, 'int 16'); end fclose(fid)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions

Question

Determine the roles of spatial layout and functionality.

Answered: 1 week ago