1 / 23

MATLAB PPTs

MATLAB basics about simulation software

Download Presentation

MATLAB PPTs

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 Presented By Narendra L Lokhande Department of Electronics and Telecommunication R C Patel Institute of Technology, Shirpur, Dist: Dhule, Maharashtra Email: narenlokhande@gmail.com

  2. History of MATLAB • Invented by Cleve Moler in late 1970s to give students access to LINPACK (Linear) and EISPACK (Eigen values) without having to learn Fortran. • MATLAB developed as an interactive system to access LINPACK and EISPACK • MATLAB developed as an interactive system to access LINPACK and EISPACK • In the 1980’s, MATLAB was rewritten in C with more functionality (such as plotting routines) • Together with Jack Little and Steve Bangert they founded Mathworks in 1984 and created MATLAB. • The Mathworks is now responsible for development, sale, and support for MATLAB • Interpreted-code based system in which the fundamental element is a matrix. • MATLAB stands for MATrixLABoratory

  3. Strengths of MATLAB • MATLAB is relatively easy to learn • MATLAB code is optimized to be relatively quick when performing matrix operations • MATLAB may behave like a calculator or as a programming language • MATLAB is interpreted, errors are easier to fix • Although primarily procedural, MATLAB does have some object-oriented elements

  4. Weaknesses of MATLAB • MATLAB is not a General Purpose Programming Language • MATLAB is an interpreted language (making it for the most part slower than a compiled language such as C++) • MATLAB is designed for scientific computation and is not suitable for some things like parsing text.

  5. APPLICATIONS OF MATLAB • Mathematical Calculations • Data Analysis & Visualization • Software Development • Simulation

  6. Getting Started with MATLAB Command Window Current Directory and Workspace Command History Launch Pad

  7. Basic Window • Command Window • Type commands • Workspace • view program variables • clear to clear • Double click on a variable to see it in the Array Editor • Command History • View past commands • Save a whole session using diary • Launch Pad • Access tools, Demos and Documentation

  8. New Look

  9. How to Open Matlab Editor • FILE • NEW • M-FILE / • Script • Other options are • Function • Class • Figure • Variable • Model • GUI • Etc Ctrl N

  10. Basic Matlab Commands • MATLAB is case-sensitive. • clc: Clear command window. • clear: removes all variables from the workspace. • clear variables:does the same thing. • clear functions: Removes all compiled M- and MEX-functions. • clear all:Removes all variables, globals, functions and MEX links. • close all: closes all the figure windows • % : used for Comments • plot: Linear plot. • plot(X, Y): plot’s vector Y versus vector X. • ; : Semicolon at the end of a statement, suppresses output. • help : when used with command gives its syntax

  11. Basic Arithmetic Operators + : Arithmetic addition - : Arithmetic subtraction * : Arithmetic multiplication / : Arithmetic division ^ : Exponent or power .* : Element by element multiplication ./ : Element by element Division .^ : Element by element Division

  12. Operators (Relational, Logical) • == equal • ~= not equal • < less than • <= less than or equal • > greater than • >= greater than or equal 1. & AND 1. pi(π) = 3.14159265… 2. | OR 2. j = imaginary unit 3. ~ NOT 3.i = same as j

  13. Built-in Waveform Functions • cos (): Generates a cosine wave • sin() : Generates a sine wave • square(): Generates a square wave • square( , duty): Generates a square with specified duty cycle • sawtooth(): Generates a sawtooth wave • sawtooth(t, 0.5): Generates a triangle wave

  14. Sine-wave Generation clc; clear all; close all; frequency = 1000; timeperiod = 1/frequency; amplitude = 1; offset = 0; t = 0:0.00001: 2*timeperiod; out = offset + amplitude* sin(2*pi*frequency*t); plot(t, out);

  15. Sine wave Program

  16. How to Execute the code Method I Select all Right Click Evaluate Selection Method II Debug RUN Other Methods Press F5 Type File name in Command window and press “Enter”

  17. Method I

  18. Method II Debug RUN

  19. Other Methods • Press F5 • Type File name in Command window and press “Enter” • Press Play Button

  20. Simulated Waveform

  21. More commands • figure : Create figure window. • xlabel(‘ ’) : Allows you to label x-axis • ylabel(‘ ’) : Allows you to label x-axis • title(‘ ’) : Allows you to give title for plot • subplot( ) : Allows you to create multiple plots in the same window

  22. Example xlabel(‘ Time ’) ylabel(‘ Amplitude ’) title(‘Generation of Sinusoidal Waveform ’)

  23. B A C

More Related