0% found this document useful (0 votes)
32 views5 pages

Matlab Matlab

This document provides an introduction to using Matlab for signals and systems applications. It begins with creating vector variables in Matlab and performing basic operations on vectors like multiplication and transposition. Then it demonstrates plotting a sine wave signal and sampling the signal at different sampling periods. Finally, it provides an example of a clipping function that limits the amplitude of a signal to a maximum value.

Uploaded by

Kareem Osta
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
32 views5 pages

Matlab Matlab

This document provides an introduction to using Matlab for signals and systems applications. It begins with creating vector variables in Matlab and performing basic operations on vectors like multiplication and transposition. Then it demonstrates plotting a sine wave signal and sampling the signal at different sampling periods. Finally, it provides an example of a clipping function that limits the amplitude of a signal to a maximum value.

Uploaded by

Kareem Osta
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 5

2010

2011

         


    
 
 :  
- .  )*+ , ( .   
    ! "# $%& 
 EF (

Matlab

Matlab


   :
 
./01 2 

3    " 4


( 56+ *78 )9/ :; < =  <> ?@(A  B CD - @ 
.1
G 9H GI( <= 
J K , ,L M0 H 0 :; N O
? P Q6+A RI9 S T (;  UV


J W X
.. V[\ ( N]^_(    
K` a   . b cdD
]^&( K -9e6A  K  _ f Z 3 Matlab )Y*/
Matlab

i l ?=  i l J (.(Y */ (; Y//0) Y "* K -9e6A 5V( g h
*0( i9 O
Matlab $

.K -9e6A
Yg T K` 0 (scalar) "eA "*( "9B
W
 K B
"* O@9 a Y ^
D( ? Matlab O
(Graphics) m 4  7no [4. K Y ^
D p hV
G - @D * *d (Functions) O9X (; K /4=X W X Y ^
D Gq ; p hV( WA N,  
J c *, *h <X  ]eh
. Matlab r
Y*/
CD
file.m

 1%B- V* B N,  ^ EF .

Function

(; BX )*+,  Y

help

BX )*+, ^&

e.( O  (; B $T" K1



  EF( . (help plot): <^ plot N, BX 
. 7h
rXcI ^BA Ss 9V
( r! *,
.lookfor(`keyword`) BX =,9 t_4 YB )*+, ^& B N, -
)* u 0 (
t0 demo BX )*+, Gq ; ^&( intro B =,9 Matlab  vY(; $w ^l Y :;  *4  < = ^&
.(demo matlab  . ^&) demonstration 
J )Y*/

21X
CD $T*
:C(#  2011

    ! "


  K B  NI
: 5 B.

Matlab

 EF N .{ / yz

vect1=[1,2,,15]

=  i l *]( x

start=1;
step=1; stop=15;
vectl=start:step:stop; % 15 points line vector

~X hV 9V ( : 4   r e =   (%) *


T} ` .vect1 u9_A BI  7nD
Oh& B T|  (;) O@( :D
.B 
uY9_A  EF 2Yd ?disp BX )*+,  (; /- r  ^

workspace

$B c q-  u9_A NI  7nD ^& x


.vect1

7n; ( vect1 i l ~-A vect2 "9B i l  $60 .( )   )*+  G
-9e6
u9/h
( ~-
T# .$B c q-  BI rBI
vect2=vect1;

.(x=1+5*1i */ "*  u %


).h 0`( /  B r e( v_comp ^(  */ N/ G  *( /   l
$^   B  d; vect3=vect1(:);
vect4=vect2(:);

. B UV *eX F


.$B c q-  * * 9_B BI N/ 7n; (
: 5 B. vect1, vect2  l 2@ K B d; scal= vect1* vect2;
mat= vect2* vect1;
vect5= vect1(:).* vect2(:);

$. )*+, *h # " ; r// :; <>  {l 9V


( (.*) ( (*)  e 9V
* * K`9_A " ; 5V


B UV )*+, .size BX )*+  (K -9e6
5V hV 
    K`9_A) u9_
* -A . B7h

 d; .r9H -A length BX )*+, ^B- "9B (; =,


G  u9_A : . FD ./  K`9_A
$. $d;
./  #  $d;
K B UV
. 7B0 ( K`9_A 4H  1
G 6eX 5=X  whos (; who BX )*+, ^& $B c q-  K`9_A -A .B X V  d;

Signals and Systems Lab HIAST 2011

21X
CD $T*
:C(#  2011

y 
:  K`" A 9Ba $0
2x +3y + 5z + t =- 1
4x +7y + 9z

=5

x +6y + 2t

=2

x +y+zt

= -5


:  I1    UV I H =X ?x(x1,x2,,xn) BI   h * ^
  
| |

.v_comp i l I H < 0

:O=/ YB  . b
(100 sec) T0
f  ]%BA (10 sec) T (* x Y4   ^ : ("#
"*  Y4d  D $^l )9/h,
.(A=10 volts 1
G %
TL) A   u =
:] ; eh(
X 
$.  ( .plot, title, xlabel, ylabel, floor, grid,

axis

  9=   "9 K B  help BX  d;


. 7 help cdD ^& * *d BX

clear all;
T=10; % period =10 sec
A=10; % amplitude =10 volts
start=0;
step=0.1;
stop=100;
t=start:step:stop-step; % 1000 points time-vector
numOfPoints=(stop-start)/step;
numOfPeriods=(stop-start)/T;
pointsInEachPeriod=floor(numOfPoints/numOfPeriods);% number of points in each
period
x=A*sin(2*pi*t/T);
figure(2);plot(t,x,'r','Linewidth',2.5); grid on; hold on;
title('sine wave signal'); xlabel('time')
ylabel('volt');
axis([start stop -1.5*A 1.5*A])

: K hY T; (" ) . h   7 ( W K hY T; "Y" /  x  
K hY TL   K B 
.( per
per =30; %sampling period in (points)
ind=0:per:numOfPoints-per+1;
y= x(ind+1) ;

Signals and Systems Lab HIAST 2011

21X
CD $T*
:C(#  2011
figure(2);scatter(ind*step,y,200,'.')

. K h_h

UX
Y - .per=80, 60, 50, 40, ,1 T . per BI Y\
function

O X *9X ( m-file Bh


W
*9X -

f u9= (sawtooth BX )*+,) y  lhA ,  D *9 )9/ example.m rY ( W


 Ga  <. xy
  u =
.y1 * *d uY9_
 G(" 20   UV
O=I . 50 Hz "Y"( 1 msec Yh
f 9=( sec
0.5

. Amp = 220. 2

volts

4d9
//0 BI 9V m %( x (N/
i )
 D 9V u(# : $T" 5

TL O X *9 5 B- )9/ x
:; ; .Am B/ P /=A B/ f( X
*h $T*  D QI  hX y  D 5= ( Am
x ( n)
y ( n) =
sign(x(n)) Am

if x(n) Am
if x(n) > Am

:   


function[y]=myFunction(x,Am)
Len=length(x);
y=zeros(1,Len);
for i1=1:Len
if abs(x(i1))> Am
y(i1)=sign(x(i1))*Am;
else
y(i1)=x(i1);
end
end

.O  N,` G/ =


:9^ :; <> WA N, :01

. G/4
V*9X   lhA ,  D $d;
O  c *,  NI( /  K B 
:)  
*  $6e $d;
% * BI K` 6X`  CDMA( Code Division Multiple Access) $ * / H )*+ X
$^ 

X )*+, 
*+ A  $6e *B .0 A  ""( h
 "9A - ^ :9.l users
*+

( ( 
[\    5T* c* :; ;) 7h B- *

9^ 
 UV BX .
*+ A
*0(
J K  i9Ba u ,D N .r ~-9A 
 
*+ A *0# K =A K 
R $. 2q $ * N .(e6
.~-9A )*+ B K =A K   u96_ 4/ A i9B   
X $. 2@ N $4/ A *h . h/
:$ * E- :(" K =A u ,D( $ * B  . _ 5 B- )9/

Signals and Systems Lab HIAST 2011

21X
CD $T*
:C(#  2011

:
*+ A : /-9A :
 :1%&     l  xy
code1=[1 1];
code2=[1 -1];

.:*

: /  :
 $V
:{1,-1} 9B
NI 10 u9=( randsrc B )*+,  )*+
$^ g s K =A *( x
data1=randsrc(1,);
data2=randsrc(1,);

$d;
1
G %B- .
*+ B K =A   rT" O X B@ EF( for /0 )*+,  $ * B cd NI x
: .  0 
; [1 1] Ss  5=X $ * B ?y ( X P ,D "A B/ :; e u(# )*+ A
.[-1 -1] :9^ Ss :- -1 P ,D "A B/
.,A    u96_ O  ST   h X  OB8 NI x
___________________________________________________________
__________________________________________________
___________________________________________________________
__________________________________________________
___________________________________________________________
__________________________________________________

Signals and Systems Lab HIAST 2011

You might also like