1 / 25

Prepared by Eng. Mohamed El- Taher Eng. Ahmed Ibrahim Ali

Training Course. Prepared by Eng. Mohamed El- Taher Eng. Ahmed Ibrahim Ali Teaching and Research assistant Mechanical design and Production Engineering Dept. Faculty of Engineering, Zagazig University 2010. INTRODUCTION. OVERVIEW.

Download Presentation

Prepared by Eng. Mohamed El- Taher Eng. Ahmed Ibrahim Ali

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Training Course Prepared by Eng. Mohamed El-Taher Eng. Ahmed Ibrahim Ali Teaching and Research assistant Mechanical design and Production Engineering Dept. Faculty of Engineering, Zagazig University 2010

  2. INTRODUCTION OVERVIEW MATLAB is the high-performance language for technical computing integrates computation, visualization, and programming in an easy-to-use environment where problems and solutions are expressed in familiar mathematical notation. The name MATLAB stands for MATrixLABoratory, because the system was designed to make matrix computations particularly easy.

  3. Why MATLAB ? MATLABlarge toolbox of numeric/image library functions. MATLABvery useful for displaying, visualizing data. MATLABhigh-level: focus on algorithm structure, MATLABallows quick prototype development of algorithms. MATLABCan be linked to C/C++, JAVA, SQL, FORTRAN, etc. MATLABCommercial product, but widely used in industry and academic.

  4. MATLAB Windows

  5. File Preferences Allows you personalize your MATLAB experience Customization your workspace

  6. File Preferences Command Window FORMAT

  7. SIMPLE MATH 2.1. Variable Types MATLAB is a weakly typed language. No need to initialize variables ! MATLAB supports various types, the most often used are »3.84 [64-bit double (default)] »‘a’ [16-bit char] Most variables you’ll deal with will be arrays or matrices of doubles or chars. Other types are also supported: complex, symbolic, 16-bit and 8 bit integers, etc.

  8. 2.2. Naming Variables To create a variable, simply assign a value to a name: »var1=3.14 »myString=‘hello world’ To remove “ans=“, use disp( ) »disp('Hello6.094‘) Variable names First Character Must Be A LETTER After That, Any Combination Of Letters, Numbers. Case Sensitive! (Var1 is Different From var1)

  9. 2.3. Special Variable

  10. 2.4. Scalars A variable can be given a value explicitly »a = 10 (shows up in workspace!) Or as a function of explicit values and existing variables »c = 1.3*45-2*a To suppress output, end the line with a semicolon »cooldude= 13/3; • 2.5. Variable Operations

  11. 2.6. Complex Numbers »c1= 1-2i »c2= 1-2j »c3= 3*(2-sqrt(-1)*3) »c4= sqrt(-3) »c5= 6+sin(0.5)*i »c6= 6+sin(0.5)*j Relates the polar form of a complex number to its rectangular form Where M is a magnitude and θ is a phase angle. The relationships among these forms are

  12. In MATLAB, the conversion between polar and rectangular forms makes use of the functions real, imag, absand angle: »c1= 1-2i » mag_c1=abs(c1) »angle_c1=angle(c1) »deg_c1= angle_c1*(pi/180) »real_c1=real(c1) »imag_c1=imag(c1)

  13. ARRAY OPERATION 3.1. Simple Arrays »x= [0 0.1*Pi 0.2*Pi 0.3*Pi 0.4*Pi 0.5*Pi 0.6*Pi 0.7*Pi 0.8*Pi 0.9*Pi Pi ]; »y=sin(x); »a=1:5, % first_value : Last_value »b=1:2:9 % first_value : increment : Last_value »c=[a b];

  14. 3.2. Array Addressing »x (3) »y (5) »x (1:5) »x (7: end) »y (3:-1:1) »x (2:2:7) »y( [8 2 9 1])

  15. 3.3. Array Construction »x =(0:0.1:1)*pi »x =linespace(0:pi:11) % (first_value, Last_value, Number of Values) »x =logspace(0:2:11) % (first_exponent, Last_ exponent, Number of Values) 10n »d=[a(1:2:5) 1 0 1];

  16. 3.4. Array Orientation Row vector »a=1:5 column vector »c=[1;2;3;4;5] »c=a’ Array matrix »g=[1 2 3; 4 5 6; 7 8 9]; »g=[1 2 3 4 5 6 7 8 9]; »d=a+ i*a »e=d’ and »e=d.’

  17. 3.5. Scalar-Array Mathematics 3.6. Array-Array Mathematics »g-2 »2*g-1 »g.^2 »g/2

  18. 3.7. Array Manipulation »a=[1 2 3; 4 5 6; 7 8 9]; »a(3,3)=0 »a(2,6)=1 »a(:,4)=4 »a=[1 2 3; 4 5 6; 7 8 9]; »b=a(3:-1:1,:) »c=[a b(:, [1 3])] »d=a(1:2, 2:3) »e=[1 3] »f=a(c,c) »g=a(:) »b(:,2)=[ ]

  19. HELP 4.1. Help Command One of the nice features of MATLAB is its help system. To learn more about a function you are to use, say sqrt, type in the Command Window

  20. 4.2. lookfor Command If you do not remember the exact name of a function you want to learn more about use command lookfor followed by the incomplete name of a function in the Command Window. In the following example we use a "word" sv

  21. 4.3. helpwin Command The helpwin command, invoked without arguments, opens a new window on the screen. You can go directly to the help text of your function invoking helpwin command followed by an argument. >> helpwin zeros

More Related