M ATLAB B ASICS. Sanjay R Joshi sanjayrjoshi@yahoo.com 18-July-2005 MATLAB for ELECTRICAL ENGINEERING ELECTRICAL ENGINEERING DEPARTMENT L.D.COLLEGE OF ENGINEERING AHMEDABAD. MATLAB - developed by Math Works Inc. http://www.mathworks.com
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation
Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement.Téléchargez la présentation en cliquant sur ce lien.Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.
F I N
Plus de contenu associé
Transcription de la présentation
MATLABBASICS Sanjay R Joshi sanjayrjoshi@yahoo.com 18-July-2005 MATLAB for ELECTRICAL ENGINEERING ELECTRICAL ENGINEERING DEPARTMENT L.D.COLLEGE OF ENGINEERING AHMEDABAD
MATLAB - developed by Math Works Inc. • http://www.mathworks.com • MATLAB - acronym for MATrix LABoratory • Matrices and arrays - the heart of MATLAB • Offers programming features - similar to other languages • Offers GUI tools
Why MATLAB is popular ? • No need to declare dimensions of a matrix as in FORTRAN or C. • Very powerful and easy-to-learn graphics capabilities. • MATLAB can be integrated with FORTRAN and C/C++ programs. • MATLAB has many toolboxes (collections of MATLAB functions) applied to specific topics like control system, symbolic manipulation, FFT etc. • MATLAB has proved to be extremely efficient and hence very fast for solving some problems.
MATLAB is an interactive system for doing numerical computations • Powerful operations can be performed using just one or two commands. • There are more than 1000 functions in the basic MATLAB product alone. • Modeling, simulation, Data analysis, exploration, and visualization and many more. • Application development, including Graphical User Interface building.
Easy to use Platform independence Predefined functions Device –independent plotting
MATLAB WINDOWS COMMAND WINDOW To give MATLAB commands at the prompt EDIT/DEBUG WINDOW To create , edit and debug the program. Type edit at the command prompt. FIGURE WINDOW To visualize graphs and plots
Provides extensive numerical resources • Over 200 reliable, accurate mathematical subprograms • The subprograms provide solutions to broad range of mathematical problems including: matrix algebra ( Linear Algebra ) • complex arithmetic • differential equations • nonlinear systems, and • many special functions
Available in all operating systems: • DOS • Windows9.x/NT • Unix • Macintosh • Same syntax for all platforms • Open system environment - access to source code • Allows - to mix MATLAB with FORTRAN or C
Simple Math » 2+2.5+106 ans = 110.5000 » 4*25 + 2^3 ans = 108 » One can use it as a calculator/scratch pad
MATLAB Variables » c = 1000; » d = 0.001; » e = a*b*c/d e = 6000000 »
MATLAB Variables • MATLAB variable are automatically created • when they are initialized. • There are three way to initializing variable in MATLAB. • Assign data to the variable in an assignment statement. Input data into the variable from the keyboard. Read data from file.
MATLAB Workspace To recall the variable » a a = 2 » Use arrow keys for scrolling through previous commands
MATLAB Workspace List of variables in the workspace » who Your variables are: a b c d e »
Variable Naming Rules • Variable names are case sensitive. For example NRe and nRe are different MATLAB variables • Variable name can contain upto 31 characters. • Start with a letter, followed by letters, numbers or underscores. • For example: SRe_2_electrical_power2by3
Control Flow Statements for n=1:10 … end while expression … end if expression … else ... end
MATLAB Files M-files Script Files Function Files MAT-files MEX-files
M Files M-files are ordinary ASCII (text) files having extension .m containing MATLAB commands
SCRIPTS Variables created by scripts remains in workspace even after the execution of it. Create a script file and edit it in MATLAB Editor called M-File Editor e.g % This is a sample Script M-file A = [ 1 2 3; 4 7 1; 9 5 0]; [x,v] = eig(A)