# Matlab Programing

• View
215

0

Embed Size (px)

### Text of Matlab Programing

• 7/29/2019 Matlab Programing

1/27

Matlab programing

M.C Saul Cantu

- Introduction to Matlab

- Variables

- Arrays

- Matrix

- Sumatory and Series

- Fourier Series

- Fourier Transformation

- Digital Signal Procesing

- Digital Image Procesing

Matlab= Matrix Laboratory

Libro:

Matlab y sus aplicaciones para la Ingenieria

David Baez.

• 7/29/2019 Matlab Programing

2/27

1 2 3 4 5 matrix 3x4

5 6 7 8 9 RAWS

10 11 12 13

COLUMNS

List Directory

>>ls

>>helpls

>>pwd

C:\users\matlab\work

>>clc

>>clear all

>>a

a is empty

>>3+2

Ans=5

>>3*2

Ans= 6

>>3/2

Ans= 1.5

>>32

Ans= 9

>>t=-2:0.001:2;

>> x=5*cos(4*pi*t)

>>plot(t,x)

• 7/29/2019 Matlab Programing

3/27

>>grid

>>t=0:0.001:5;

>>x=exp(-t);

>>plot(t,x)

>>grid

>>t=0:0.001:10

X=sawtooth

DC Component

X=0.5+0.5sawtooth(2*pi*t)

X=0.5+0.5square(2*pi*t)

X=0.5+0.2square(2*pi*t,80)

Vector X Vector = v.*v

General Formula-excos(2ft+)

Figure Another Window

>>t=0:0.001:5;

>>m=[1+0.5*sin(2*pi*t)];

>>c=cos(40*pi*t);

>>s=m*c

>>plot(t,m)

• 7/29/2019 Matlab Programing

4/27

>>grid

>>figure

>>plot(t,c)

>>grid

>>figure

>>plot(t,s)

>>grid

--------------------------------------------------------------------------------------------------------------

HOMEWORK

Amplitude modulation is defined as the multiplication of one time-domain signal byanother time-domain signal. The signals may or may not be complex in nature, i.e.,either or both signals may contain harmonics components. It is impossible tohave amplitude modulation unless at least two different signals are involved. Thesignals may be electrical in nature, or they can bevibration signals. Modulation isinherently a non-linear process, and always gives rise to frequency componentsthat did not exist in either of the two original signals

Amplitude Modulated Wave FormIf the amplitude-modulated signal shown here is passed through

a frequency analyzer, the following spectrum is the result. The highest peak isthe carrier frequency. The right-hand peakis the upper sideband, and hasa frequency of the carrier frequency plus the modulating frequency. The left-hand peak or lower sideband has a frequency of the carrier minus themodulating frequency. The sidebands are sometimes called sum and differencefrequencies because of their symmetrical spacing around the carrier.

Amplitude modulation also occurs in sound reproducing equipment, where it iscalled Intermodulation Distortion. The sum and difference frequencies are not in

• 7/29/2019 Matlab Programing

5/27

musical harmony with the tones that cause them, making intermodulation aparticularly noticeable form of sound distortion.

Spectrum of Modulated Wave Form

Rectified Wave Form

Recovered Modulating Signal

This process of demodulation is exactly what happens in an AM radio -- the carrieris a very high frequency signal generated by the radio station, and themodulating signal is the voice or music that constitutes the program. The radio

receives the modulated carrier, amplifies it, and rectifies (detects) it to recover theprogram.

AM SIGNAL

• 7/29/2019 Matlab Programing

6/27

FM SIGNAL

>>t=0:0.001:5;>>m=10*cos(2*pi*t)>>c=cos(20*pi*t)>>plot(t,m)>>grid>>figure>>plot(t,c)>>s=cos(20*pi*t*tm)>>plot(t,s)

Hold on: to unit 2 graphics

• 7/29/2019 Matlab Programing

7/27

With sawtooth

Frecuency= dfase/t

Cardinal sin

Sin(t)=sin2/t.

HOMEWORK

(100)(101)/2=5050

>>n=0;>>for k=1:100>>n=n+k;End>>n

5050

• 7/29/2019 Matlab Programing

8/27

SERIES

1+2+3+4n

FIBONACCI SERIE

0,1,1,2,3,4,5,8,13,21

FOURIER SERIE

Sinx= () ()

Cosx= () ()

Ex=

HOMEWORKFibonacci Serie

>>x(1)=0;>>x(2)=1;>>for i=3:20>>x(i)=x(i-1)+X(i-2)>>end>>x

• 7/29/2019 Matlab Programing

9/27

EULER IDENTIES

cos jsin

Cos=

Sin

FOURIER SERIES

The sumatory of all frecuencies are iqual to the total frecuency.

• 7/29/2019 Matlab Programing

10/27

Example:Make a matlab program to compute the Fourier serie of

X(t)=1v; x=0>>for k=1:2:3>>x=x+(4/(pi*k).*sin(2*pi*k*t)>>end>>plot(t,x)>>grid

EXPONENCIAL SERIE

>>x=1>>e=1>>for n=1:10E=e+(xn)/prod(1:n)>>end>>e

>>y=1

>>x=1>>for n=1:10>>y=y+[(-1)n(n-1)*[x(2n-1)]/prod(2n-1)>>End>>y

• 7/29/2019 Matlab Programing

11/27

FOURIER TRANSFORMATION

x(t)= ()

rect=1;-1/2> f=-10;0.001:10

>>xf=0j

>>for t=-.5:0.01:0.5

xF=xF+1*exp(-j*2*pi*f*t)

end

>>plot(xF,f)

• 7/29/2019 Matlab Programing

12/27

EXAMPLE

>>f=-10:.001:10

>>xF=0;

>>for t=-10:.01:10;

xF=xF+cos(4*pi*t),*exp(-j*2*pi*f*t)

>>end

>>plot(F,xF)

RECTANGULAR PULSE

>>rectpuls()

>>t=-5:0.001:5

>>x=rectpuls(1/2);

>>plot(t,x)

>>x=rectpuls(2*t)

TRIANGULAR PULSE

• 7/29/2019 Matlab Programing

13/27

>>t=-1:0.001:1>>x=tripuls(t2)>>plot(t,x)

GAUSS PULSE

• 7/29/2019 Matlab Programing

14/27

DIGITAL PROCESSING

>>sound(y)aleluya

>>sound(y,Fs/2)

low>>soun(y,Fa*2)fast>>sound(y(1:2:end),Fs/2)Normal

X=size(y)Z=zeros(2*x,1)

[x,fs,b]>>sound(x,fs,b)>>z=repeat(x,2,2)

>>z=repeat(x,2,1)>>sound(z,Fs,b)

RESULTANT

7302123

>>size(y)436224>>x=x(1:436224,2)>>y=y(1:436224,2);>>x=x(1:436224,1);>>reslultant=[x,y]>>sound(resultant,fs);End

• 7/29/2019 Matlab Programing

15/27

IMAGE PROCESSING

0black

1..254255white

EXAMPLE

>>f=0:255>>f=repmat(f,256,1);

>>size(f)256 256>>imshow(f)>>whos fName size bytes class attributesF 256x256 52428 double>>imshow(f)>>f=uint8(f);>>who fName size bytes class attributesF 256x256 uint8

HOMEWORK>>f=zeros(256);>>imshow(f)>>f=(1:end,128)=1;>>(128,1:end)=1;Imshow f>>for x=1:128>>for (x,x)=1;

• 7/29/2019 Matlab Programing

16/27

FACULTAD DE INGENIERIA MECANICA Y ELECTRICA

MATLAB PROGRAMING

ING. SAUL CANTU

NOMBRE: FELIPE ANTONIO VAZQUEZ GOVEA

MATRICULA: 1299592

SALON: 7204

DIA: 6

12 DE ABRIL DEL 2013

SAN NICOLAS DE LOS GARZA NUEVO LEON

• 7/29/2019 Matlab Programing

17/27

• 7/29/2019 Matlab Programing

18/27

• 7/29/2019 Matlab Programing

19/27

• 7/29/2019 Matlab Programing

20/27

• 7/29/2019 Matlab Programing

21/27

• 7/29/2019 Matlab Programing

22/27

• 7/29/2019 Matlab Programing

23/27

• 7/29/2019 Matlab Programing

24/27

• 7/29/2019 Matlab Programing

25/27

• 7/29/2019 Matlab Programing

26/27

• 7/29/2019 Matlab Programing

27/27

Documents
Documents
Mobile
Documents
Documents
Documents
Documents
Documents
Documents
Documents
Documents
Documents