1 / 24

Introduction to Matlab

Introduction to Matlab. By: Maha AlMousa. Outline:. What is MATLAB ? MATLAB desktop environment. Variables. Operations. Definition of algorithms. Introduction to M-files. What is Matlab ?. MATLAB is an interactive system for numerical computation.

foxkaren
Download Presentation

Introduction to Matlab

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. Introduction to Matlab By: MahaAlMousa

  2. Outline: • What is MATLAB? • MATLAB desktop environment. • Variables. • Operations. • Definition of algorithms. • Introduction to M-files.

  3. What is Matlab? • MATLAB is an interactive system for numerical computation. • MATLAB is a modern programming language and problem-solving environment.

  4. MATLAB desktop environment. Command Window type commands

  5. Example

  6. Command History view past commands save a whole session using diary

  7. Workspace Viewa list of variables created by MATLAB. Double click on a variable to see it in the Array Editor

  8. Another way to create a variable

  9. To assign a value to bbb

  10. MATLAB special variables

  11. Operators (arithmetic) + addition / division -Subtraction ^ power * multiplication

  12. Operator precedence rules • () parentheses. • ^ power. • - negation. • */ \ all multiplication and division. • + - addition and subtraction.

  13. Example

  14. Scripts and functions Both scripts and functions allow you to reuse sequences of commands by storing them in program files

  15. Some functions in MATLAB

  16. >>y=x^0.5; >>y=x^(1/2); >>y=sqrt(x); Example

  17. Creating Variable • Names • Can be any string of upper and lower case letters along with numbers and underscores but it must begin with a letter • Reserved names are IF, WHILE, ELSE, END, SUM, etc. • Value • This is the data the is associated to the variable; the data is accessed by using the name.

  18. Definition of algorithms. • An algorithm is the sequence of steps needed to solve a problem.

  19. Interduction to m-file

  20. The previous command will display the editor window.The editor creates an m-file that can be used to write your MATLAB programs.

  21. To execute a program

  22. Example Create a script in a file named triarea.m that computes the area of a triangle: • b = 5; • h = 3; • a = 0.5*(b.*h) • After you save the file, you can call the script from the command line: • triarea • a = 7.5000

  23. function a = triarea(b,h) • a = 0.5*(b.*h); • end

More Related