Anda di halaman 1dari 24

In The Name Of Allah

Book:
Lets Learn Matlab
By:
Ahmed Salah
Faculty Of Engineering
Electrical Eng. Department
Power & Machines Section
Email:
d1e.h4rd@yahoo.com

:
- .
- .
- .
- .
-.
-.
- .



.
===========

:
:
- .

.- .

============

:
:
Workspace :

Command Window :

)>>(
MatLab Interpreted

) ; ( .

Command History :

Current Directory :


C:MATLAB6p5work
) (... .
============
-:

-: polyval
..
-:
-:
]Y=[1 -1
-:.
x=1
polyval(y,1) -:
..
-:.
x=4
polyval(y,4) -:
..3
-:
-:
]Z=[1 -3 4
-:.
x=1
polyval(z,1) -:
..2
-:.
x=4

x-1

(x^2)-(3x)+4

polyval(z,4) -:
..8

===========
-: matlab

-: poly
..
-:
1 -1
-:
:
]X=[1;-1
:
)Y=Poly(x

:
]Y=[1 0 -1
-:
2 5 7
-:
:
]X=[2;5;7
:
)Y=Poly(x

:
]Y=[1 -14 59 -70
===========
-:matlab
-:roots

..
-:
]A=[1 -2 1
)roots(a
-:
X=1
X=1
-:
]B=[2 -1 -1
roots(b) -:
-:
X=-0.5000
X=1.0000

-:
]C=[6 41 -8 -7
roots(c) -:
-:
X=0.5000
X=-0.3333
X=-7.0000
-:
]D=[5 16 -2 -16 -3
roots(d) -:
-:
X=-0.2000
X=1.0000
X=-1.0000
X=-3.0000

===========
-: matlab

-:

-:

-:

-:

-:
-:
-:

clc
clear
close all
]a=[1 2;2 1
]b=[5;4
z=inv(a)*b
)x=z(1
)y=z(2
abc
x=1
y=2
===========

-:
)Clear(a
a ..
x=pi
pi 3,1416 ..x
)y=sqrt(4
..y
1/0
inf
0/0
nan

. not a number
===========
-:
ceil
floor ..

===========
-:

i
:
j
:
;i=3
a=1+3*i
i 3
a ) () + ( i

b=1+3i
i :
===========
-:
-:

z=3+4i
z 3 . 4

-:
)Real(z
z . 3

-:
)Imag(z
z . 4

-:

-:
)Angle(z
z . 0.9273

-:
))Angle=atan(imag(z)/real(z
z . 0.9273

-:

)Abs(z
z . 5

-:
:
) ( z
) . ( v

===========
-:
-:

===========

===========

-:
)Length(a
:

.

===========

-:
-:
a :
A(11)=120

A .
.
.

.
-:

)( .

===========
-:
:
)( )(..
- -: ..
;a(11)=11
;a(12)=12
;a(13)=13

- -:

:
]A(11:13)=[11;12;13

===========
-:
:
..
]A(6:10)=[0;0;0;0;0

===========

-:
..
] [=)A(10

===========

-:
..
] [=)A(6:10

-:

===========

) (Max
..

-:

===========

) (Min
..

-:

===========

-:

-:

===========

===========

) (Sum
..

===========
-:
a :

b :

-:

)Size(a
..
..

===========

-:
)Size(a,1
a
a ..

===========

-:
)Size(a,2
a
a ...

===========

-:
b(2,5)=42
..b

===========

-:
]b(4,1:4)=[31 54 13 11
..
..

===========

-:
b(3,1)=0
..0

===========

-:
b(1:2,1:3)=0

..

-:

===========

][=)b(3,:
..b

===========

-:
][=)b(:,4
..b

-:

===========

)b(1,3
.
)b(1,:
.
)b(:,2
.
)b(1:2,:
.
)b(:,1:2
.
)b(2,end
.

===========

-:
a :

:
)b=max(a


)c=max(b
.

===========

-:
)b=min(a


)c=min(b
.

===========

-:
)b=sum(a

)c=sum(b
.

===========

-:
)b=prod(a


)c=prod(b
.

===========

-:
)z=diag(a
a .z

===========
-:
))w=sum(diag(a
a .w

-:

))s=prod(diag(a
a .s

===========

-:
)q=magic(3
..

)q=magic(9
..

===========
-:
-:
area . trapz
-:
) Area(x,y .
) Trapz(x,y .
-:
clc
clear
close all
;)x=(0:0.1:10
;)y=sin(x
;)area(x,y
;)trapz(x,y

)'xlabel('x axis
)'ylabel('y axis
grid
-:

-:

===========
-:
. axis
-:
clc
clear
close all
)]axis([-10,10,-10,10
-:
-10
10
-10
10
-:

===========
-:
-:
Clc

Clear
Close all
Hold on
)]Axis([-10,10,-10,10
)[x y]=Ginput(6
)Plot(x,y
-:
- hold on
..
- axis - ..
- ) (.. ginput
- .. plot
-:

===========
-:
-:
clc
clear
close all
;)X=(0:0.1:10
;)Y=sin(x
;)Plot(x,y
;)'Xlabel('x axis
;)'Ylabel('y axis
;)'Title('the sine wave graph by a.salah
Grid
-:
- ..
- x 0 .. 10
- step 0.1 ..
- y ..
- plot .. grid ..
- xlabel x..
- ylabel y..
- title ..
===========
-:

-:
clc
clear
close all
;)X=(0:0.1:10
;)Y=cos(x
;)Plot(x,y
;)'Xlabel('x axis
;)'Ylabel('y axis
;)'Title('the cose wave graph by a.salah
Grid
-:
- ..
- x 0 .. 10
- step 0.1 ..
- y ..
- plot .. grid ..
- xlabel x..
- ylabel y..
- title ..
===========

-:
-:
clc
clear
close all
;)x=(0:0.1:10
;)y=sin(x
;)z=cos(x
hold on
)'*plot(x,y,'r
)'*plot(x,z,'g
)'legend('sine wave','cose wave
grid
hold off
;)'xlabel('x axis
;)'ylabel('y axis & z axis
;)'title('the sine & cose wave graph by a.salah
-:
- hold on hold off plot
grid ...
..
- legend ..
===========

-:
-:
clc
clear

close all
;)x=(0:0.1:10
;)y=sin(x
;)z=cos(x
;)plot(x,y
;)'xlabel('x axis
;)'ylabel('y axis
;)'title('the sine wave graph by a.salah
grid
figure
;)plot(x,z
;)'xlabel('x axis
;)'ylabel('y axis
;)'title('the cose wave graph by a.salah
grid
-:
figure
-:
figure.1 ...sine wave graph
figure.2 ..cose wave graph
..
===========

-:
-:
clc
clear
close all
;)x=(0:0.1:10
;)y=sin(x
;)z=cos(x
)subplot(1,2,1
)plot(x,y
;)'xlabel('x axis
;)'ylabel('y axis
;)'title('the sine wave graph by a.salah
grid
)subplot(1,2,2
)plot(x,z
;)'xlabel('x axis
;)'ylabel('z axis
;)'title('the cose wave graph by a.salah
grid
-:
-:
- ..
) subplot(1,2,
..

- ..

) subplot(2,1,
..

..
===========

-:
-:
clc
clear
close all
;)x=(0:0.1:10
;)y=sin(x
;)z=cos(x
;)v=exp(x
)subplot(3,1,1
)plot(x,y
;)'xlabel('x axis
;)'ylabel('y axis
;)'title('the sine wave graph by a.salah
grid
)subplot(3,1,2
)plot(x,z
;)'xlabel('x axis
;)'ylabel('z axis
;)'title('the cose wave graph by a.salah
grid
)subplot(3,1,3
)plot(x,z
;)'xlabel('x axis
;)'ylabel('v axis
;)'title('the exp curve graph by a.salah
grid
-:
subplot plot -:


..
===========

Anda mungkin juga menyukai