MATLAB 1 - Introduction
MATLAB 1 - Introduction
MATLAB
In this set of information files we provide an introduction to the software applications
package MATLAB. You may ask why have we chosen MATLAB!. The reason is
that as well as "eing a good teaching environment# the package is an Industry
$tandard. %e shall use the package to support the curriculum in a variety of courses.
&owever# this won't "e your only use of the package. In later courses you may well
meet MATLAB tool"o(es associated with particular applications. $o# what is
MATLAB
MATLAB is an interactive system for doing numerical computations.
A numerical analyst called )leve Moler wrote the first version of MATLAB in the
*+,-s. It has since evolved into a successful commercial software package.
MATLAB relieves you of a lot of the mundane tasks associated with solving
pro"lems numerically. This allows you to spend more time thinking# and
encourages you to e(periment.
MATLAB makes use of highly respected algorithms and hence you can "e
confident a"out your results.
.owerful operations can "e performed using /ust one or two commands.
You can "uild up your own set of functions for a particular application.
0(cellent graphics facilities are availa"le and the pictures can "e inserted into
Word documents with very little difficulty.
You will use the material in this and the other MATLAB information files as your
principal source of information# the actual files that you use will depend on your
course and you may well not need all those listed in the ne(t section. %e suggest that
you work through the recommended material in order. &owever# that is not necessary
and you may /ump a"out from section to section as you wish. There will "e no formal
MATLAB lectures# the support will "e availa"le in regular la"oratory sessions in the
10I$ .) Teaching La"oratories# 23*- or A456.
MATLAB *.* 26 March, 2002
1.1 MATLAB information files
MATLAB * Introduction
MATLAB 5 .lotting graphs
MATLAB 7 m8files
MATLAB 3 9ectors
MATLAB 6 Matrices
MATLAB 4 )alculus
MATLAB , .rogramming
MATLAB : 1urther MATLAB
MATLAB + $imulink
MATLAB *- 1ourier series
Appendi(
You won't "e using all these files in your current course. Also# since these files will
"e used "y people on a variety courses there may "e one or two su"sections which are
not relevant to your studies at present. The necessary information will "e posted on
$tudy;et.
1.2 Starting up
You will "e working in a %indows environment. )lick on the Start "utton in the
"ottom left8hand corner of the screen. )hoose Programs then MATLAB Release 12
then MATLAB R12. The MATLAB command window and two other windows will
eventually appear together with the statement <To get started# select MATLAB! &elp
from the &elp menu'# see 1igure *.*.
MATLAB *.5 26 March, 2002
1igure *.*. MATLAB windows.
You do not need to select &elp# you can start immediately with the MATLAB
command prompt=
>>
You should save a record of your session and any files that you create. The procedure
for doing this is descri"ed in section *.5.
1.3 MATLAB laboratory workshop exerises
The purpose of these e(ercises is to help you to get to know the MATLAB
environment and to support your understanding of the mathematical techni>ues which
are presented in the lectures. The e(ercises are not e(haustive# they give you an
introduction to the topic and you should find other e(ercises to try. In particular the
e(ercises in the te(t "ook or tutorial sheets would "e a good place to start.
You should keep a record of your MATLAB sessions# collecting them together in a
la"oratory workshop folder. This work"ook will "e collected towards the end of the
course and will comprise part of the coursework assessment.
MATLAB *.7 26 March, 2002
The "est way to keep a record of your session is to use the command diary. %hen
you start your session type the command
>> diary X:[Link]
>> % YOUR NAME, session numer
>> date
ans !
""#$an#"%%"
Then everything you type will "e recorded in the file yourfile1t!t on your floppy or
?ip disk where X is the e(ternal device drive onto which your work is "e copied# either
a floppy or ?ip disk. The name of the drive depends on the la"oratory in which you
are working# see local details. It's up to you what name you use for yourfile1 "ut you
should write your name on the ne(t line which is started with a percentage sign# %.
This is MATLAB's comment sym"ol# anything which follows % is ignored "y
MATLAB so you can use it to make comments during your sessions. You should use
a different file for each session so your second session would "e saved in file
yourfile2t!t. These files# will "e used to produce your workshop folder. %e suggest
that you print them at regular intervals rather than wait until the end of the course
when it may "e inconvenient to print all the files. Below you can see the start to a
typical session.
>> diary a:[Link] % a is t&e flo''y dis( dri)e
>> % A*AN +A,-E., session 1
>> format (om'a(t
>> date
ans !
""#$an#"%%"
>> format (om'a(t
>> 'i
ans !
/.1011
>> diary off % session is finis&ed 2 (lose diary
>> 3uit
MATLAB *.3 26 March, 2002
The diary command will not save any plots that you may have produced. To save
these you must save them to a file# eg. a Word file# as e(plained in section 5.6.
@sually we use MATLAB in a systematic manner to develop the solution to a
pro"lem. In the MATLAB information files we are running through a series of
e(ercises in a which is somewhat different manner. In order that earlier results do not
interfere with current calculations it is a good idea to start each su"section with the
two commands
>> (lear all
>> format s&ort
this should ensure that your results will "e in the same format as those in the files. It
is a matter of good practice to use the (lear all command regularly in your work
unless you are very sure that you do not wish to erase earlier results.
1.! MATLAB as a alulator
The "asic arithmetic operators are 4 # 5 6 7 and these are used in con/unction with
"rackets= 89. The sym"ol 7 is used to get e(ponents# ie. powers= "70!11.
You should type in the commands shown following the prompt= >>
>> "4/605:
ans !
:.;:%%
>>
;ow# is this calculation performed as "4/6805:9 or "48/6095:
MATLAB works according to the priorities=
*. >uantities in "rackets#
5. powers "4/7""4<!11#
7. 5 6# working left to right 8/506:!1"6:9#
3. 4 ## working left to right 8/40#:!;#:9"
Thus# the earlier calculation was for "48/6095: "y priority 7.
MATLAB *.6 26 March, 2002
1.# $umbers an% formats
MATLAB recognises several different kinds of num"ers# see Ta"le *.*
Ta"le *.*. MATLAB num"ers.
Type 0(amples
Integer
Aeal
)omple(
Inf
;a;
1/1", "1;=<;
1."/0, 1%.;1
/."1 0./i 8i!
-1
9
-nfinity 8result of di)idin> y %9
Not a Numer, %6%
The <e' notation is used for very large or very small num"ers=
#1./01"e4%/!#1./01"1%
/
!#1/01."
#1./01"e#%1!#1./01"1%
#1
!#%.1/01"
All computations in MATLAB are done in dou"le precision# which means a"out *6
significant figures. The format# the way in which MATLAB prints num"ers# is
controlled "y the <format' command# see Ta"le *.5. Type &el' format for a full list.
Ta"le *.5. MATLAB format commands.
)ommand 0(ample of output for 1%5'i
>> format s&ort
>> format lon>
>> format s&ort e
>> format lon> e
>> format rational
>> format (om'a(t
>> format loose
/1.011" 80 de(imal 'la(es9
/.101:<"1:/:=<;< 810 de(imal 'la(es9
/.1011e4%%1 8e4! means *-
!
9
/.101:<"1:/:=<;</e4%%1
/::%611/ 8ans?er as a fra(tion9
.u''resses extra line feeds
@uts a(A extra line feeds 8default9
$hould you wish to switch "ack to the default format then format will suffice.
The command
>> format (om'a(t
is also useful in that it suppresses "lank lines in the output thus allowing more
information to "e displayed.
MATLAB *.4 26 March, 2002
1.& 'ariables
)onsider the following calculations=
>> "407/
ans !
11
>> ans6/
ans !
""
The result of the first calculation is la"elled ans "y MATLAB and is used in the
second calculation where its value is changed. &owever# we can use our own names
to store num"ers=
>> a!"407/
a !
11
>> !a6/
!
""
so that a has the value 44 and 55 " = and the values can "e used in su"se>uent
calculations. These are e(amples of assig#me#t stateme#ts in which values are
assigned to varia"les. 0ach varia"le must "e assigned a value "efore it may "e used
on the right8hand8side of an assignment statement.
1.( 'ariable names
Legal #ames consist of any com"ination of letters and digits# starting with a letter. It
is very important to remem"er that MATLAB commands are case$se#siti%e, ie you
must distinguish "etween lower case and upper case characters.
These names are allowa"le=
NetBost, *eft"@ay, x/, X/, C":(:
These are not allowa"le
Net#Bost, "'ay, %x, Dsi>n
@se names that reflect the values they represent.
There are s&ecial #ames that you should avoid using
e's BC5.55-3e8*4C5
863
D#
the largest num"er such that 14e's is indistinguisha"le from *.
MATLAB *., 26 March, 2002
'i B = C7.*3*6+ED
If you wish to do arithmetic with comple( num"ers# "oth i and ' have the value
*
unless you change them.
>> i,E, i!"
ans !
% 4 1.%%%%i
ans !
% 4 1.%%%%i
i !
"
(B. MATLAB recognises "oth i and ' as
*
"ut it always returns i and not '.
MATLAB is case$se#siti%e# ie upper case and lower case sym"ols are considered to
"e different varia"les.
>> 'i
ans !
/.1011
>> @i
FFF Ba'italiCed internal fun(tion @iG Ba's *o(A may e
on.
MATLAB doesn't recognise @i# it looks for a varia"le with the name @i. The line
"eginning FFF and in red te(t is a commentary "y MATLAB indicating where the
error may arise.
1.) Suppressing output
%e often do not want to see the result of intermediate calculations. To do this we
terminate the assignment statement or e(pression with a semi8colon.
>> x!<G y!"5x6/G C!y7"4y5s3rt8x9
C !
:0
The values of x and y are hidden. %e also note here that we can place several
statements on one line# separated "y commas or semi8colons.
It is a good idea to get used to using the semi8colon especially when using arrays. It
is possi"le to have pages and pages of output. If you find a calculation going on and
on you can stop it "y pressing the keys Btrl and B simultaneously.
MATLAB *.: 26 March, 2002
1.* +eyboar% aelerators
%e can recall previous MATLAB commands "y using the and cursor keys.
Aepeatedly pressing will review the previous commands the most recent first. To
re8e(ecute the command simply press the return key. To edit# use the cursor keys
or
to move "ackwards and forwards through the line. )haracters may "e
inserted "y typing at the current cursor position or deleted using the +el key. This
process is most commonly used when long command lines have "een mistyped or
when you want to re8e(ecute a command that is very similar to one used previously.
To recall the most recent command starting with f# say# type f at the prompt followed
"y . $imilarly# typing fo followed "y will recall the most recent command
starting with fo.
1.1, Built-in funtions
Trigonometric functions
Those recognised "y MATLAB are sin# (os# tan and their arguments must "e in
radians. eg to work out the coordinates of a point on a circle of radius 4 centred at
the point ( ) *# 5
and having an elevation 4- 7 = radians=
>>format s&ort
>> x!1415(os8'i6/9, y!"415sin8'i6/9
x !
0.%%%%
y !
;.1<1"
The inverse trig functions are called asin# a(os# atan# as opposed to the usual arcsin
or sin
8*
etc.# and the result is in radians.
>> a(os816"9, asin8#19, atan819
ans !
1.%0;"
ans !
#1.:;%=
ans !
%.;=:0
>> % (&e(A
>> 'i6/, #'i6", 'i60
ans !
MATLAB *.+ 26 March, 2002
1.%0;"
ans !
#1.:;%=
ans !
%.;=:0
Fther elementary functions
These include s3rt# ex'# lo># lo>1%
>> x!0, s3rt8x9, ex'8x9, lo>8x9, lo>1%8x7"#19
x !
0
ans !
"
ans !
:0.:<="
ans !
1./=1/
ans !
1
(B lo>1% gives logs to the "ase *-.
ex' denotes the e(ponential function# ( ) e(p
!
! e =
# and its inverse function is lo>.
%e have ( ) ( ) ( ) ( )
e(p log log e(p ! ! ! = =
(B ( ) ( ) log ln ! !
.
>> format lon> e
>> ex'8lo>8<99, lo>8ex'8<99
ans !
<.%%%%%%%%%%%%%%"e4%%%
ans !
<
and we see a very small rounding error in the first calculation. A more complete list
of elementary functions is given in the Appendi(.
%e can perform calculations to any prescri"ed precision. MATLAB's )'a command
has a default precision of 75 digits# however we can prescri"e the num"er of digits as
in the following e(ample in which we shall calculate e
=
>> ex'8197'i
ans !
"/.10%;
>> format lon>
MATLAB *.*- 26 March, 2002
>> ex'8197'i
ans !
"/.10%1<"1/";;<";
>> )'a8ex'8197'i9
ans !
"/.10%1<"1/";;<";/<%;/1;0;0/1=%"=
>> )'a8Hex'8197'iH9
ans !
"/.10%1<"1/";;<"1<%%:;"<%=1/1;<0<
>> )'a8Hex'8197'iH,:%9
ans !
"/.10%1<"1/";;<"1<%%:;"<%=1/1;<0=:0;/=%"111%1"0"1%1
;otice the use of the single >uotes in the final two e(pressions. This synta( is
essential to o"tain the re>uired accuracy. %ithout them# as in )'a8ex'8197'i9#
MATLAB calculates ex'819 and 'i separately# to a"out *4 digits# then performs the
operation.
%e can perform calculations to any prescri"ed precision. MATLAB's )'a command
has a default precision of 75 digits# however we can prescri"e the num"er of digits as
in the following e(ample in which we shall calculate e
=
>> ex'8197'i
ans !
"/.10%;
>> format lon>
>> ex'8197'i
ans !
"/.10%1<"1/";;<";
>> )'a8ex'8197'i9
ans !
"/.10%1<"1/";;<";/<%;/1;0;0/1=%"=
>> )'a8Hex'8197'iH9
ans !
"/.10%1<"1/";;<"1<%%:;"<%=1/1;<0<
>> )'a8Hex'8197'iH,:%9
ans !
"/.10%1<"1/";;<"1<%%:;"<%=1/1;<0=:0;/=%"111%1"0"1%1
;otice the use of the single >uotes in the final two e(pressions. This synta( is
esse#tial to o"tain the re>uired accuracy. %ithout them# as in )'a8ex'8197'i9#
MATLAB *.** 26 March, 2002
MATLAB calculates ex'819 and 'i separately# to a"out *4 digits# then performs the
operation.
1.11 Algebrai simplifiation
BiD ( )
4
a " +
>> ex'and88a49719
ans !
a714[Link]"4"%5a7/57/41:5a7"570415a57:471
>> fa(tor8ans9
ans !
8a4971
BiiD
! y
e
+
>> ex'and8ex'8x4y99
ans !
ex'8x95ex'8y9
BiiiD ( ) ( ) u % ) u % ) + +
>> syms u ) ?
>> (olle(t88u4)4?958u#)#?99
ans !
#?7"#"5)5?48u4)958u#)9
>> (olle(t88u4)4?958u#)#?9,)9
ans !
#)7"#"5)5?48u4?958u#?9
>> (olle(t88u4)4?958u#)#?9,u9
ans !
u7"48)4?958#)#?9
>> ex'and8ans9
ans !
u7"#)7"#"5)5?#?7"
BivD
5 5 5
5 u %u % ) + +
>> fa(tor8u7"4"5)5u4)7"#?7"9
ans !
8u4)4?958u4)#?9
MATLAB *.*5 26 March, 2002
BvD ( ) ( )
5 5
7cos 3 7sin 3 ! ! +
>> syms x
>> sim'lify8/5(os805x97"4/5sin805x97"9
ans !
/
BviD
( ) ( ) 7ln * !
e
+
>> syms x
>> sim'lify8ex'8#/5lo>8x94199
ans !
16x7/5ex'819
BviiD
( )
5
cos sin ! ! + there are two commands for simplification# sim'lify and
sim'le=
>> sim'lify8(os8x94s3rt88#sin8x997"99
ans !
(os8x94(s>n8sin8x995sin8x9
>> sim'le8(os8x94s3rt88#sin8x997"99
sim'lify:
(os8x94(s>n8sin8x995sin8x9
radsim':
(os8x94sin8x9
(omine8tri>9:
(os8x9416"58"#"5(os8"5x997816"9
fa(tor:
(os8x948sin8x97"97816"9
ex'and:
(os8x948sin8x97"97816"9
(omine:
(os8x9416"58"#"5(os8"5x997816"9
(on)ert8ex'9:
16"5ex'8i5x9416"6ex'8i5x948#16058ex'8i5x9#
16ex'8i5x997"97816"9
(on)ert8sin(os9:
(os8x948sin8x97"97816"9
(on)ert8tan9:
81#tan816"5x97"96814tan816"5x97"94
07816"958tan816"5x97"6814tan816"5x97"97"97816"9
MATLAB *.*7 26 March, 2002
(olle(t8x9:
(os8x948sin8x97"97816"9
ans !
(os8x94sin8x9
BviiiD $u"stitute ( )
3
in cos ! !
=
>> syms x
>> sus8(os8x9, x, 'i609
ans !
%.;%;1
>> sus8(os8x9, x, sym8'i9609
ans !
16"5"7816"9
Bi(D 1actorisation of 353: and 363+7*+73:6+,
>> fa(tor80"0=9
ans !
" " " / / :<
>> fa(tor8sym8H0"0=H99
ans !
8"97/58/97"58:<9
$o we have the prime factors 5#5#5#7#7#6+ and we can write
7 5
353: 5 7 6+ =
.
>> fa(tor8sym80:0</1</0=:<;99
ans !
80:0</1</0=:<;9
$o we see that 363+7*+73:6+, is prime.
MATLAB *.*3 26 March, 2002
1.12 Solution of [Link]
MATLAB can solve linear and non8linear e>uations in one or more varia"les. 1or
systems of linear e>uations see MATLAB file 6# matrices.
0>uations with one varia"le
%e write the e>uation in the form ( ) - f ! =
and use the sol)e command.
BiD
5
7 * - ! ! + =
>> syms x % ?e must ensure t&at x is defined symoli(
>> sol)e8x7"4/5x#19
ans !
I #/6"416"51/7816"9J
I #/6"#16"51/7816"9J
so the result is
*7 7
5 5
(B MATLAB returns a sym"olic value. %e can o"tain a numerical value as
follows=
>> doule8ans9
ans !
%./%"=
#/./%"=
BiiD sin cot - ! ! + =
>> sol)e8sin8x94(ot8x99
ans !
I atan816"58#"4"5:7816"997816"968#16"5:7816"9416"994'iJ
I #atan816"58#"4"5:7816"997816"968#16"5:7816"9416"99#'iJ
I atan816"58#"#"5:7816"997816"9,16"416"5:7816"99J
I atan8#16"58#"#"5:7816"997816"9,16"416"5:7816"99J
>> doule8ans9
ans !
"."/;%
#"."/;%
% 4 1.%11/i
% # 1.%11/i
BiiiD 7
t
e t = +
>> syms t
>> sol)e8ex'8t9#s3rt8t9#/9
ans !
1.0/0:0"0/<;<//"="/:<%1"";11/"%;0
MATLAB *.*6 26 March, 2002
MATLAB can not find a sym"olic solution and so finds a numerical solution correct
to 75 digits.
BvD
5
7 - ! a! + + =
>> syms x a
>> sol)e8x7"4a5x4/9
ans !
I #16"5a416"58a7"#1"97816"9J
I #16"5a#16"58a7"#1"97816"9J
so the solution is
5
* *
5 5
*5 a
MATLAB chooses ! to "e the varia"le and finds the solution in terms of a. )ompare
this with
>> syms x a
>> sol)e8x7"4a5x4/,a9
ans !
#8x7"4/96x
BviD *
a!
e ! a = +
>> (lear all
>> syms x a
>> sol)e8ex'8a5x9#s3rt8a4x9419
Karnin>: Ex'li(it solution (ould not e found.
> -n B:LMAM*ANR1"LtooloxLsymoli(Lsol)e.m at line 1/1
-n B:LMAM*ANR1"LtooloxLsymoli(LDsymLsol)e.m at line 0<
ans !
I em'ty sym J
MATLAB can't do everythingG
0>uations with two varia"les
BiD
5 5
5
*
! y
! y
+ =
+ =
%e write the e>uations as strings# * and 5 s s # then use sol)e.
>> syms x y
>> s1!Hx7"4y7"#"H, s"!Hx4y#1H
s1 !
x7"4y7"#"
s" !
x4y#1
>> Ix, yJ!sol)e8s1, s"9
x !
MATLAB *.*4 26 March, 2002
I 16"#16"5/7816"9J
I 16"416"5/7816"9J
y !
I 16"416"5/7816"9J
I 16"#16"5/7816"9J
so the solution is
7 7 * *
5 5 5 5
# ! y = = m
>> doule8Ix, yJ9
ans !
#%./11% 1./11%
1./11% #%./11%
BiiD
5 5
7 *
! y a
! y a
+ =
+ =
>> syms x y a
>> s1!Hx7"4y7"#aH, s"!Hx4y#/5a41H
s1 !
x7"4y7"#a
s" !
x4y#/5a41
>> Ix, yJ!sol)e8s1, s"9
x !
I #16"4/6"5a#16"58#14=5a#<5a7"97816"9J
I #16"4/6"5a416"58#14=5a#<5a7"97816"9J
y !
I #16"4/6"5a416"58#14=5a#<5a7"97816"9J
I #16"4/6"5a#16"58#14=5a#<5a7"97816"9J
BiiiD
( )
5 5
5
*
! y
e !
! y
+
=
=
>> (lear all % a >ood idea to do t&is o((asionally
>> syms x y
>> s1!Hex'8#x7"#"5y7"9#xH, s"!Hx#y41H
s1 !
ex'8#x7"#"5y7"9#x
s" !
x#y41
>> Ix, yJ!sol)e8s1, s"9
x !
.<1:1</::1"<%%;=<:;11=::<=/<%%=<0e#1
y !
1.%<1:1</::1"<%%;=<:;11=::<=/<%%<
MATLAB *.*, 26 March, 2002
1.13 /artial frations
1or the e(pression
5
* 5 7
5
* 5 7
" ! " ! "
a ! a ! a
+ +
+ +
MATLAB returns the partial fraction e(pansion
as
* 5
* 5
r r
*
! & ! &
+ +
.
)onsider
5
5
7 : 47
7 *-
! !
! !
=
>> format rational % results as rational numers
>> !I/,#=,#1/JG a!I1,#/,#1%JG Ir,',AJ!residue8,a9
r !
#0
:
' !
:
#"
A !
/
so that
( )
5
5
7 : 47 3 6 3 6
7 7
7 *- 6 5 6 5
! !
! ! ! ! ! !
= + + = +
+
1.12 0omplex numbers
BiD
* 5 + ' =
>>format s&ort
>> C!1#"5E
C !
1.%%%% # ".%%%%i
>> real8C9, ima>8C9 % real and ima>inary 'arts
ans !
1
ans !
#"
>> as8C9 % modulus
ans !
"."/11
>> an>le8C9 % ar>ument in radians
ans !
#1.1%;1
MATLAB *.*: 26 March, 2002
BiiD ( ) ( ) 5 6 7 + ' ' = +
>> C!8"#E958:4/E9
C !
1/.%%%% 4 1.%%%%i
BiiiD
3
* *
cos sin
3 3 5 5
'
+ e ' '
= = =
>> C!ex'8#E5'i609
C !
%.;%;1 # %.;%;1i
BivD $olve the cu"ic e>uation
7 5
5 5 * - ! ! ! + =
>> sol)e8Hx7/#"5x7"4"5x#1!%H9
ans !
I 1J
I 16"#16"5i5/7816"9J
I 16"416"5i5/7816"9J
>> doule8ans9 % floatin> 'oint form
ans !
1.%%%%
%.:%%% # %.=11%i
%.:%%% 4 %.=11%i
1.1! /artial frations
1or the e(pression
5
* 5 7
5
* 5 7
" ! " ! "
a ! a ! a
+ +
+ +
MATLAB returns the partial fraction e(pansion
as
* 5
* 5
r r
*
! & ! &
+ +
.
)onsider
5
5
7 : 47
7 *-
! !
! !
=
>> format rational % results as rational numers
>> !I/,#=,#1/JG a!I1,#/,#1%JG Ir,',AJ!residue8,a9
r !
#0
:
' !
:
#"
A !
/
MATLAB *.*+ 26 March, 2002
so that
( )
5
5
7 : 47 3 6 3 6
7 7
7 *- 6 5 6 5
! !
! ! ! ! ! !
= + + = +
+
1.12 0omplex numbers
BiD
* 5 + ' =
>>format s&ort
>> C!1#"5E
C !
1.%%%% # ".%%%%i
>> real8C9, ima>8C9 % real and ima>inary 'arts
ans !
1
ans !
#"
>> as8C9 % modulus
ans !
"."/11
>> an>le8C9 % ar>ument in radians
ans !
#1.1%;1
BiiD ( ) ( ) 5 6 7 + ' ' = +
>> C!8"#E958:4/E9
C !
1/.%%%% 4 1.%%%%i
BiiiD
3
* *
cos sin
3 3 5 5
'
+ e ' '
= = =
>> C!ex'8#E5'i609
C !
%.;%;1 # %.;%;1i
BivD $olve the cu"ic e>uation
7 5
5 5 * - ! ! ! + =
>> sol)e8Hx7/#"5x7"4"5x#1!%H9
ans !
I 1J
I 16"#16"5i5/7816"9J
I 16"416"5i5/7816"9J
>> doule8ans9 % floatin> 'oint form
ans !
1.%%%%
MATLAB *.5- 26 March, 2002
%.:%%% # %.=11%i
%.:%%% 4 %.=11%i
1.1# Bibliography
Borse HI B*++,D (umerical methods )ith MATLAB, a resource for scie#tists a#d
e#gi#eers# .%$ .u"lishing. A good source of m8files for numerical applications.
Much of the material is advanced.
2a"ney IB and &arman TL B5--*D Masteri#g Simuli#* -# .rentice &all. An
e(cellent introduction to $imulink.
&anselman 2 and Littlefield B B5--*D Masteri#g MATLAB 6# .rentice &all. An
advanced "ut very good reference te(t.
&igham 2I and &igham ;I B5---D MATLAB .uide# $iam. A mathematical# and
rather advanced# approach to MATLAB.
&unt BA# Lipsman AL and Aosen"erg IM B5--*D A guide to MATLAB for "egi##ers
a#d e!&erie#ced users# )am"ridge @niversity .ress. A very good introductory
te(t. It includes an introductory chapter on $imulink.
Jermit $ and 2avis TA B5--5D MATLAB Primer# )hapman and &allK)A) .ress.
This small hand"ook is an ideal companionL it contains all you need to know
a"out MATLAB.
Jhara" A and Huenther AB B5--5D A# i#troductio# to #umerical methods, a
MATLAB a&&roach. A mathematical and fairly advanced te(t.
Marchand . B*+++D .ra&hics a#d ./0s with MATLAB# )A) .ress. An advanced
"ut very good te(t for graphics.
MATLAB *.5* 26 March, 2002