Sie sind auf Seite 1von 16

c

c c

<  
¯ c c c
 cc    c  c
c
c
c
c
c
c
c
c
¯ c
c
1. Abstract

2. Defination

3. History of MATLAB

4. Syntax of MATLAB

5. Programming in MATLAB

6. Interaction with other languages

7. How to operate MATLAB

8. Building matrices using MATLAB

9. Variables

10. Functions

11. Miscellaneous features

12. Limitions of MATLAB

13. Alternatives to MATLAB

14. Various versions of MATLAB and their release history

15. The appliction of MATLAB in engineering education


S Sc
SS is a numerical computing environment and fourth generation
programming language. c

MATLAB allows matrix manipulation, plotting of functions and data, implementation


of algorithms, creation of user interfaces, and interfacing with programs in
other languages. c

SS ccwas invented in the late 1970s by Cleve Moler, then chairman of the
computer science department at the University of New Mexico. He designed it to
give his students access to LINPACK and EISPACK without having to learn Fortran.c

Jack Little, an engineer, joined with Moler and Steve Bangert. They rewrote
MATLAB in C and founded The MathWorks in 1984 to continue its development.
These rewritten libraries were known as JACKPAC.c

In 2000, SS was rewritten to use a newer set of libraries for matrix
manipulation, LAPACK.c

SS , the application, is built around thecSS language. c

The simplest way to executecSS code is to type it in at the prompt, >> , in


the Command Window, one of the elements of thecSS Desktop.c

MATLAB is also a programming language. By creating a file with the extension


.m we can easily write and run programs. c

SS callows us to build matrices, use functions and variables including


arithmatic and logical functions. It also allows various shortcuts to work fast,
save time and avoid repetion of the same task by saving it.

It has found various applications in engineering education. For example :

For the compilation equation of motion, Newton¶s Second Law or


Langrangian Equations of second order is being used.The equations of
motions of these machine systems are are in most cases systems of non-
linear algebraic-differential equations. The reason or non-linear equationsis
non-linearity of kinematical bonds, passive resistances, dampers or elastic
elements. Their analytical solutionis limste to a few exceptional incidents. In
research description of non-linear systems it is necessary using numerical
methods in connection with computer systems. Compared to other possible
software products  appears to be most successful for teaching.
SS c
c
 ¯ ¯
c
cSS c
SS is a numerical computing environment and fourth generation
programming language. Developed by The MathWorks, MATLAB allows
matrix manipulation, plotting of functions and data, implementation of
algorithms, creation of user interfaces, and interfacing with programs in
other languages. Although it is numeric only, an optional toolbox uses the
MuPAD symbolic engine, allowing access to computer algebra capabilities. An
additional package, Simulink, adds graphical multidomain simulation and
Model-Based Design for dynamic and embedded systems.

In 2004, MathWorks claimed that SS was used by more than one
million people across industry and the academic world.

¯
c
cSS c
SS (meaning  c  ) was invented in the late 1970s by
Cleve Moler, then chairman of the computer science department at the
University of New Mexico. He designed it to give his students access to
LINPACK and EISPACK without having to learn Fortran. It soon spread to
other universities and found a strong audience within the applied
mathematics community. Jack Little, an engineer, was exposed to it during a
visit Moler made to Stanford University in 1983. Recognizing its commercial
potential, he joined with Moler and Steve Bangert. They rewrote MATLAB in
C and founded The MathWorks in 1984 to continue its development. These
rewritten libraries were known as JACKPAC. In 2000, SS was rewritten
to use a newer set of libraries for matrix manipulation, LAPACK.

SS was first adopted by control design engineers, Little's specialty, but
quickly spread to many other domains. It is now also used in education, in
particular the teaching of linear algebra and numerical analysis, and is
popular amongst scientists involved with image processing.

 Sc
cSS c
SS , the application, is built around thec SS language. The
simplest way to executecSS code is to type it in at the prompt, >> , in
the Command Window, one of the elements of thecSS Desktop. In this
way, SS can be used as an interactive mathematical shell. Sequences
of commands can be saved in a text file, typically using the SS Editor,
as a script or encapsulated into a function, extending the commands
available.

c 
S¯ c¯ cSS c
MATLAB is also a programming language. By creating a file with the
extension .m we can easily write and run programs. If we were to create a
program file myfile.m in the MATLAB language, then we can make the
command myfile from MATLAB and it will run like any other MATLAB
function. There is no need to compile the program since MATLAB is an
interpretative (not compiled) language. Such a file is called an m-file.

c
¯ S¯
c¯ c
 cS Sc
SS can call functions and subroutines written in the C programming
language or FORTRAN. A wrapper function is created allowing MATLAB data
types to be passed and returned. The dynamically loadable object files
created by compiling such functions are termed "MEX-files" (for ATLAB
ecutable).

Libraries written in Java, ActiveX or .NET can be directly called fromc


SS and manycSS libraries (for example XML or SQL support) are
implemented as wrappers around Java or ActiveX libraries. Calling MATLAB
from Java is more complicated, but can be done with MATLAB extension,
which is sold separately by MathWorks.

Through the SS Toolbox for Maple, SS commands can be called
from within the Maple Computer Algebra System, and vice versa.


c
c
ScSS c
c
Matlab can be operated by typing the following sequence of commands. The
designation RET means that you should type the "return" key; this is implicit
after every command.

To bring up MATLAB from from the operating system prompt

lab%

first type matlab

lab% matlab RET

This will present the prompt

>>
†ou are now in MATLAB.

If you are using the X Window system on the Mathematics Department


workstations then you can also start MATLAB from the Main Menu by
selecting "matlab" from the "Math Applications" submenu. A window should
pop up and start MATLAB. When you run MATLAB under the window system,
whether you start from the menu or a system prompt, a small MATLAB logo
window will pop up while the program is loading and disappear when
MATLAB is ready to use.

When you want to exit the MATLAB, type exit

>> exit RET

¯¯ cS¯c¯ cSS c


Matlab has many types of matrices which are built into the system. A 7 by 7
matrix with random entries is produced by typing
ñand(7)

†ou can generate random matrices of other sizes and get help on the rand
command within matlab:

ñand(2,5)

help ñand

Another special matrix, called a Hilbert matrix, is a standard example in


numerical linear algebra.

hilb(5)

help hilb

A 5 by 5 magic square is given by the next command:

magic(5)

help magic
A magic square is a square matrix which has equal sums along all its rows
and columns.

Some of the standard matrices from linear algebra are easily produced:

eye(6)

zeñ (4,7)

ne(5)

†ou can also build matrices of your own with any entries that you may want.

[1 2 3 5 7 9]

[1, 2, 3; 4, 5, 6; 7, 8, 9]

[1 2 RET 3 4 RET 5 6]

S¯S c
Matlab has built-in variables like pi, eps, and ans. Their values can be learnt
from the Matlab interpreter.
pi

ep

help ep

At any time, to know the active variables we can use who:

wh

help wh

The variable an will keep track of the last output which was not assigned to
another variable.
magic(6)

an

x = an

x = [x, eye(6)]

Since we have created a new variable, x, it should appear as an active


variable.

wh

To remove a variable, type:

cleañ x

wh

 ¯
c
S = magic(4)

Taking the transpose of S:

Note that if the matrix A has complex numbers as entries then the Matlab
function taking A to A' will compute the transpose of the conjugate of A
rather than the transpose of A.

Other arithmetic operations are easy to perform.

3*a
-a

a+(-a)

b = max(a)

max(b)

Some Matlab functions can return more than one value. In the case of max
the interpreter returns the maximum value and also the column index where
the maximum value occurs.

[m, i] = max(b)

min(a)

b = 2* ne(a)

a*b

We can use matrix multiplication to check the "magic" property of magic


squares.

S = magic(5)

b = ne(5,1)

S*b

v = ne(1,5)

v*S

There are many functions which we apply to scalars which Matlab can apply
to both scalars and matrices.

in(d)

exp(d)

l g(d)

ab(d)
c

c¯S 
c Sc
MATLAB is case sensitive, that is

´a´ i n t the ame a ´S´

If this proves to be an annoyance, the command

caeen

will toggle the case sensitivity off and on.

The MATLAB display only shows 5 digits in the default mode. The fact is that
MATLAB always keeps and computes in a double precision 16 decimal places
and rounds the display to 4 digits. The command

f ñmat l ng

will switch to display all 16 digits and

f ñmat h ñt

will return to the shorter display. It is also possible to toggle back and forth
in the scientific notation display with the commands

f ñmat h ñt e

and

f ñmat l ng e

It is not always necessary for MATLAB to display the results of a command


to the screen. If you do not want the matrix A displayed, put a semicolon
after it, A;. When MATLAB is ready to proceed, the prompt >> will appear.

Sometimes we have spent much time creating matrices in the course of our
MATLAB session and we would like to use these same matrices in our next
session. We can save these values in a file by typing

ave filename
This creates a file

filenamemat

which contains the values of the variables from our session. If we do not
want to save all variables there are two options. One is to clear the variables
off with the command

cleañ a b c

which will remove the variables a,b,c. The other option is to use the
command

ave x y z

which will save the variables x,y,z in the file filename.mat. The variables can
be reloaded in a future session by typing

l ad filename

When you are ready to print out the results of a session, you can store the
results in a file and print the file from the operating system using the ´pñint´
command appropriate for your operating system. The file is created using
the command

diañy filename

Once a file name has been established we can toggle the diary with the
commands

diañy n

and

diañy ff

This will copy anything which goes to the screen (other than graphics) to the
specified file.

c
c

¯¯S¯
c
cSS c
For a long time there was criticism that because SS is a proprietary
product of The MathWorks, users are subject to vendor lock-in. Recently an
additional tool called the SS c  under the Application
Deployment tools section has been provided to deploy SS functions as
library files which can be used with .NET or Java application building
environment. However, the computer where the application has to be
deployed needs MCR (SS Component Runtime) for the SS files
to function normally. MCR can be distributed freely with library files
generated by the MATLAB compiler.

SS , like Fortran, Visual Basic and Ada, uses parentheses, e.g. y = f(x),
for both indexing into an array and calling a function. Although this syntax
can facilitate a switch between a procedure and a lookup table, both of
which correspond to mathematical functions, a careful reading of the code
may be required to establish the intent.

Mathematical matrix functions generally accept an optional argument to


specify a direction, while others, like plot, do not, and so require additional
checks. There are other cases where MATLAB's interpretation of code may
not be consistently what the user intended. (e.g. how spaces are handled
inside brackets as separators where it makes sense but not where it doesn't,
or backslash escape sequences which are interpreted by some functions like
fprintf but not directly by the language parser because it wouldn't be
convenient for Windows directories). What might be considered as a
convenience for commands typed interactively where the user can check
thatcSS does what the user wants may be less supportive of the need
to construct reusable code.

Array indexing is one-based which is the common convention for matrices in


mathematics, but does not accommodate any indexing convention of
sequences that have zero or negative indices. For instance, in SS the
DFT (or FFT) is defined with the DC component at index 1 instead of index 0,
which is not consistent with the standard definition of the DFT in any
literature. This one-based indexing convention is hard coded into SS ,
making it difficult for a user to define their own zero-based or negative-
indexed arrays to concisely model an idea having non-positive indices.

Code written for a specific release of SS often does not run with
earlier releases as it may use some of the newer features. To give just one
example: save('filename','x') saves the variable x in a file. The variable can be
loaded with load('filename') in the samec SS release. However, if saved
with SS version 7 or later, it cannot be loaded with SS version 6
or earlier. As workaround, in SS version 7 save('filename','x','-v6')
generates a file that can be read with version 6. However, executing
save('filename','x','-v6') in version 6 causes an error message.

S S¯c
cSS c

MATLAB has a number of competitors.

There are free open source alternatives to MATLAB, in particular GNU


Octave, FreeMat, and Scilab which are intended to be mostly compatible
with the MATLAB language (but not the MATLAB desktop environment), or
systems with a similar, but not compatible syntax like Euler Math Toolbox.
Among other languages that treat arrays as basic entities (array
programming languages) are APL and its successor J, FORTRAN 95 and
2003, as well as the statistical language S (the main implementations of S
are S-PLUS and the popular open source language R).

There is one web / cloud based alternative - Monkey Analytics - which


provides a modern web interface on top of GNU Octave or Python (including
matplotlib, NumPy, SciPy and more).

There are also several libraries to add similar functionality to existing


languages, such as Perl Data Language for Perl and SciPy together with
NumPy and Matplotlib for Python.

c
S¯
c¯
c
cSS cS c ¯c
Sc ¯
c
¯
c Sc Sc Sc
MATLAB 1.0 R? 1984
MATLAB 2 R? 1986
MATLAB 3 R? 1987
MATLAB 3.5 R? 1990
MATLAB 4 R? 1992
MATLAB
R7 1994
4.2c
MATLAB 5.0 R8 1996
MATLAB 5.1 R9
MATLAB 1997
R9.1
5.1.1
MATLAB 5.2 R10
MATLAB 1998
R10.1
5.2.1
MATLAB 5.3 R11
MATLAB 1999
R11.1
5.3.1
MATLAB 6.0 R12 2000
MATLAB 6.1 R12.1 2001
MATLAB 6.5 R13 2002
MATLAB
R13SP1
6.5.1
2003
MATLAB
R13SP2
6.5.2
MATLAB 7 R14
MATLAB 2004
R14SP1
7.0.1
MATLAB
R14SP2
7.0.4 2005
MATLAB 7.1 R14SP3
MATLAB 7.2 R2006a
2006
MATLAB 7.3 R2006b
MATLAB 7.4 R2007a
2007
MATLAB 7.5 R2007b
MATLAB 7.6 R2008a
2008
MATLAB 7.7 R2008b
MATLAB 7.8 R2009a
2009
MATLAB 7.9 R2009b

 cS¯S¯
c
cSS c¯ c ¯ ¯ c
S¯
c
A knowledge of dynamical characterstics of mechanical systems is an
inherent part of engineering. It is important for the construction and design
of machine and also for control and regulation of different processes.
Therefore part of Bachelors and Masters studies in Electrical Engineering
are courses in Electrical Power Engineering and Control Engineering. The
courses proceed on a basis, which the students have received on physics in
first two years of their studies. The courses widen their technical and
practical knowledge. The students get to know of methods of vectors and
analytic static systems, kinematics planar mechanisms and dynamical
systems with one or more degrees of freedom. For the compilation equation
of motion, Newton¶s Second Law or Langrangian Equations of second order is
being used.The equations of motions of these machine systems are are in
most cases systems of non-linear algebraic-differential equations. The
reason or non-linear equationsis non-linearity of kinematical bonds, passive
resistances, dampers or elastic elements. Their analytical solutionis limste to
a few exceptional incidents. In research description of non-linear systems it
is necessary using numerical methods in connection with computer systems.
Compared to other possible software products  appears to be most
successful for teaching.

Das könnte Ihnen auch gefallen