Beruflich Dokumente
Kultur Dokumente
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
9. Variables
10. Functions
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
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).
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.
lab%
>>
ou are now in MATLAB.
ou can generate random matrices of other sizes and get help on the rand
command within matlab:
ñand(2,5)
help ñand
hilb(5)
help hilb
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
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)]
wh
cleañ x
wh
¯
c
S = magic(4)
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.
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
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
caeen
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
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
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.
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
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.