Selasa, 13 Januari 2015

KAMI MEMBERIKAN KURSUS MATLAB - KURSUS MATLAB ONLINE Skripsi, Tesis, DISERTASI 081219449060





Synthesizing Geometries for 21st Century Electromagnetics
Interfacing MATLAB with CAD
Lecture 19           1
Lecture Outline
             Text files in MATLAB
             String manipulation in MATLAB
             STL files
             STL files in MATLAB
             Visualizing surface meshes in MATLAB
             Generating faces and vertices using MATLAB
             Converting surfaces meshes from objects on a 3D grid
             Point clouds
             Importing custom polygons into SolidWorks
Lecture 19           Slide 2

Reading and
Writing Text Files
in MATLAB
Opening and Closing Files
A file is opened in MATLAB as read‐only with the following command.

% OPEN ASCII STL FILE
fid = fopen(‘pyramid.STL’,'r');       %’r’ is read-only for safety
if fid==-1
error('Error opening file.');

end

Use ‘w’ to write files.

A file is closed in MATLAB with the following command.
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB ONLINE - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060.  Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Format bimbingannya tugas-tugas yang bisa membantu Skripsi, Tesis, DISERTASI
Bimbingan dilakukan secara online bisa lewat WA atau email
Dijamin Bisa, atau bisa mengulang kembali. Kami juga dapat membantumembuatkan aplikasi atau program matlab/lainnya. Anda akan dilatih oleh Tim Profesional - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060.   Email: kursusmatlab@gmail.com

% CLOSE FILE
fclose(fid);
Open and closing the file is always the first and last thing you do. WARNING! Always close open files!
Lecture 19           4

Reading a Line from the Text File
A line of text is read from the text file using the following command.

% READ A LINE OF TEXT
L = fgetl(fid);
You can read and display an entire text file with the following code.

% READ AND DISPLAY AN ENTIRE TEXT FILE
while feof(fid)==0
% Get Next Line from File
L = fgetl(fid);
% Display the Line of Text
disp(L);
end
Lecture 19           5
Writing a Line to the Text File
A line of text is written to the text file using fprintf().
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB ONLINE - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060.  Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Format bimbingannya tugas-tugas yang bisa membantu Skripsi, Tesis, DISERTASI
Bimbingan dilakukan secara online bisa lewat WA atau email
Dijamin Bisa, atau bisa mengulang kembali. Kami juga dapat membantumembuatkan aplikasi atau program matlab/lainnya. Anda akan dilatih oleh Tim Profesional - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060.   Email: kursusmatlab@gmail.com
% WRITE A LINE OF TEXT
fprintf(fid,’solid pyramid\r\n’);
This writes “solid pyramid” to the file followed by carriage line return.

Numbers can also be written to the file.

% Write Facet Normal to File
N = [ 1.234567 68.76543 1.592745 ];
L = '        facet normal %8.6f %8.6f %8.6f\r\n'; fprintf(fid,L,N);
This writes “        facet normal 1.234567e0 6.876543e1 1.592745e0” to the file followed by carriage line return.

Lecture 19           6

ANSI Formatting -- Summary

ESCAPE CHARACTERS
For most cases, \n is sufficient for a single line break.                 However, if you are creating a file for use with Microsoft        Notepad, specify a combination of
\r\n to move to a new line.

CONVERSION CHARACTERS

Lecture 19           7
ANSI Formatting – Conversion Characters

Lecture 19           8

ANSI Formatting – Flags
Action   Flag        Example
Left‐justify.         '–'           %-5.2f
Print sign character (+ or –).          '+'           %+5.2f
Insert a space before the value.   ' '            % 5.2f
Pad with zeros.  '0'           %05.2f
Modify selected numeric conversions:
             For %o, %x, or %X, print 0, 0x, or
0X prefix.
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB ONLINE - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060.  Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Format bimbingannya tugas-tugas yang bisa membantu Skripsi, Tesis, DISERTASI
Bimbingan dilakukan secara online bisa lewat WA atau email
Dijamin Bisa, atau bisa mengulang kembali. Kami juga dapat membantumembuatkan aplikasi atau program matlab/lainnya. Anda akan dilatih oleh Tim Profesional - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060.   Email: kursusmatlab@gmail.com

             For %f, %e, or %E, print decimal
point even when precision is 0.
             For %g or %G, do not remove
trailing zeros or decimal point.     '#'           %#5.0f
Lecture 19           9
String
Manipulation in
MATLAB

Parsing Strings
A line of text can be parsed into separate words using sscanf().

S = 'Hello Class';
T = sscanf(S,'%s %s');

T =
HelloClass


S = 'Hello Class';
T = sscanf(S,'%*s %s');

T =
Class

skip string
You can also extract numbers from a string using sscanf().
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB ONLINE - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060.  Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Format bimbingannya tugas-tugas yang bisa membantu Skripsi, Tesis, DISERTASI
Bimbingan dilakukan secara online bisa lewat WA atau email
Dijamin Bisa, atau bisa mengulang kembali. Kami juga dapat membantumembuatkan aplikasi atau program matlab/lainnya. Anda akan dilatih oleh Tim Profesional - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060.   Email: kursusmatlab@gmail.com


S = 'I am 25 years old and 6 feet tall.';       N =
N = sscanf(S,'%*s %*s %f %*s %*s %*s %f %*s %*s');         25
6
Lecture 19           11
Checking for Specific Words in Strings (1 of 3)
You can perform an exact comparison between two strings using strcmp().

s1 = 'cat';
s2 = 'dog';            c =
c = strcmp(s1,s2);             0
s1 = 'cat';
s2 = 'Cat';            c =
c = strcmp(s1,s2);             0
s1 = 'cat';
s2 = 'cat';             c =
c = strcmp(s1,s2);             1
Lecture 19           12

Checking for Specific Words in Strings (2 of 3)
You can do the same camparison, but case insensitive using strcmpi().

s1 = 'cat';
s2 = 'dog';            c =
c = strcmpi(s1,s2);            0
s1 = 'cat';
s2 = 'Cat';            c =
c = strcmpi(s1,s2);            1
s1 = 'cat';
s2 = 'cat';             c =
c = strcmpi(s1,s2);            1
Lecture 19           13
Checking for Specific Words in Strings (3 of 3)
You can find the occurrence of one string inside another using strfind().


s1 = 'University of Texas at El Paso'; s2 = 'Hawaii';
ind = strfind(s1,s2);

ind = []


s1 = 'University of Texas at El Paso'; s2 = 'Texas';
ind = strfind(s1,s2);

ind = 15

Lecture 19           14

Converting Between Strings and Numbers
You can convert a string to a number using str2num().


S = '534';
N = str2num(S);

N = 534


S = '2.74E-10';
N = str2num(S);

N = 2.74E-10

Similarly, you can convert numbers to strings using num2str().
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB ONLINE - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060.  Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Format bimbingannya tugas-tugas yang bisa membantu Skripsi, Tesis, DISERTASI
Bimbingan dilakukan secara online bisa lewat WA atau email
Dijamin Bisa, atau bisa mengulang kembali. Kami juga dapat membantumembuatkan aplikasi atau program matlab/lainnya. Anda akan dilatih oleh Tim Profesional - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060.   Email: kursusmatlab@gmail.com

N = 1234;
S = num2str(N);

S = 1234


N = 1.23456789;
S = num2str(N);

S = 1.2346


N = 1.23456789;
S = num2str(N,'%1.6f');

S = 1.234568

Lecture 19           15

STL Files

What is an STL File?
STL – Standard Tessellation Language
This file format is widely used in rapid prototyping. It contains only a triangular mesh of an objects surface. Color, texture, materials, and other attributes are not represented.

They can be text files or binary. Binary is more common because they are more compact. We will look at text files because that is more easily interfaced with MATLAB.

Lecture 19           Slide 17
Surface Mesh
Despite this sphere really being a solid object, it is represented in an STL file by just its surface.
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB ONLINE - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060.  Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Format bimbingannya tugas-tugas yang bisa membantu Skripsi, Tesis, DISERTASI
Bimbingan dilakukan secara online bisa lewat WA atau email
Dijamin Bisa, atau bisa mengulang kembali. Kami juga dapat membantumembuatkan aplikasi atau program matlab/lainnya. Anda akan dilatih oleh Tim Profesional - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060.   Email: kursusmatlab@gmail.com

Solid Object
STL Representation
Lecture 19           18

STL File Format
solid name

facet normal nx ny nz
outer loop
vertex vx,1 vy,1 vz,1
vertex vx,2 vy,2 vz,2

This set of text is repeated for every triangle on the surface of the object.
                                                    v1
v2 v1   v3 v1

vertex vx,3 vy,3 vz,3

nˆ 
v

v v  v 

endloop
endfacet
endsolid name

                                      
2             1             3             1
v3
v2

Bold face indicates a keyword; these must appear in lower case. Note that there is a space in “facet normal” and in “outer loop,” while there is no space in any of the keywords beginning with “end.” Indentation must be with spaces; tabs are not allowed. The notation, “{…}+,” means that the contents of the brace brackets can be repeated one or more times. Symbols in italics are variables which are to be replaced with user-specified values. The numerical data in the facet normal and vertex lines are single precision floats, for example, 1.23456E+789. A facet normal coordinate may have a leading minus sign; a vertex coordinate may not.
Lecture 19           19
Example STL File

solid pyramid
facet normal -8.281842e-001 2.923717e-001 -4.781524e-001
outer loop
vertex 4.323172e-018 1.632799e-017 6.495190e-001 vertex 3.750000e-001 7.081604e-001 4.330127e-001 vertex 3.750000e-001 0.000000e+000 0.000000e+000
endloop endfacet
facet normal 0.000000e+000 2.923717e-001 9.563048e-001
outer loop
vertex 7.500000e-001 0.000000e+000 6.495190e-001 vertex 3.750000e-001 7.081604e-001 4.330127e-001 vertex 0.000000e+000 0.000000e+000 6.495190e-001
endloop endfacet
facet normal 8.281842e-001 2.923717e-001 -4.781524e-001
outer loop
vertex 3.750000e-001 -1.632799e-017 0.000000e+000 vertex 3.750000e-001 7.081604e-001 4.330127e-001 vertex 7.500000e-001 0.000000e+000 6.495190e-001
endloop endfacet
facet normal 0.000000e+000 -1.000000e+000 0.000000e+000
outer loop
vertex 3.750000e-001 0.000000e+000 0.000000e+000 vertex 7.500000e-001 0.000000e+000 6.495190e-001 vertex 0.000000e+000 0.000000e+000 6.495190e-001
endloop endfacet
endsolid pyramid

An STL file is essentially just a list of all the triangles on the surface of an object.

Each triangle is defined with a surface normal and the position of the three vertices.

Lecture 19           Slide 20

A Single Triangle

facet normal -8.281842e-001 2.923717e-001 -4.781524e-001
outer loop
vertex 4.323172e-018 1.632799e-017 6.495190e-001 vertex 3.750000e-001 7.081604e-001 4.330127e-001 vertex 3.750000e-001 0.000000e+000 0.000000e+000
endloop endfacet

Vertex 3


1.            Facet normal must follow right‐hand rule and point outward from object.
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB ONLINE - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060.  Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Format bimbingannya tugas-tugas yang bisa membantu Skripsi, Tesis, DISERTASI
Bimbingan dilakukan secara online bisa lewat WA atau email
Dijamin Bisa, atau bisa mengulang kembali. Kami juga dapat membantumembuatkan aplikasi atau program matlab/lainnya. Anda akan dilatih oleh Tim Profesional - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060.   Email: kursusmatlab@gmail.com

a)            Some programs set this to [0;0;0] or convey shading information.
b)            Don’t depend on it!
2.            Adjacent triangles must have two
common vertices.
3.            STL files appear to be setup to handle
arbitrary polygons.  Don’t do this.
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB ONLINE - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060.  Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Format bimbingannya tugas-tugas yang bisa membantu Skripsi, Tesis, DISERTASI
Bimbingan dilakukan secara online bisa lewat WA atau email
Dijamin Bisa, atau bisa mengulang kembali. Kami juga dapat membantumembuatkan aplikasi atau program matlab/lainnya. Anda akan dilatih oleh Tim Profesional - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060.   Email: kursusmatlab@gmail.com

Facet Normal
Vertex 1

Vertex 2

Lecture 19           Slide 21
Warnings About Facet Normals
             Since the facet normal can be calculated from the vertices using the right-hand rule, sometimes the facet normal in the STL file contains other information like shading, color, etc.
             Don’t depend on the right-hand rule being followed.
             Basically, don’t depend on anything!
Lecture 19           22

Reading/Writing
STL Files in
MATLAB
How to Store the Data
We have N facets and ≤ 3N vertices to store in arrays.

F(N,3) Array of triangle facets
V(?,3) Array of triangle vertices
Many times, the number of vertices is 3N. Observing that many of the triangle facets share vertices, there will be redundant vertices
Lecture 19           24

Lazy Array of Vertices (1 of 2)

vx,1

vy ,1

5
vz,1 

            

V vx,2

vy ,2

vz,2      8

            

vx,M 
V is an array

vy ,M

vz,M  
2
4

containing the    6
position of all the
vertices in Cartesian        9
coordinates.

M is the total number of
vertices.               1
Lecture 19

7
3             11
12
10           25

Lazy Array of Vertices (2 of 2)
There is redundancy here. Twelve vertices are stored, but the device is really only composed of four.
Kami ada di Jakarta Selatan. KAMI MEMBERIKAN KURSUS MATLAB ONLINE - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060.  Kami membuka kursus Matlab untuk pemula dan mahasiswa atau insinyur yang ingin memperdalam Matlab dan menerapkan dalam bidang teknikal, engineering, rekayasa, dsb. Format bimbingannya tugas-tugas yang bisa membantu Skripsi, Tesis, DISERTASI
Bimbingan dilakukan secara online bisa lewat WA atau email
Dijamin Bisa, atau bisa mengulang kembali. Kami juga dapat membantumembuatkan aplikasi atau program matlab/lainnya. Anda akan dilatih oleh Tim Profesional - HUBUNGI MASTER ENGINEERING EXPERT (MEE) 081219449060.   Email: kursusmatlab@gmail.com

While an inefficient representation,

this is probably not worth your time fixing.

SolidWorks exports a lazy array of vertices.

Tidak ada komentar:

Posting Komentar