>>  Lectures >>  Matlab 2

 Navigator

## 2.4 Assignment Solutions - Lecure 2

### 2.4.1 Part A

 hw1partA.m

Red Layer:

subimageR = blackrect(558:643,622:703,1); image(subimageR);

Green Layer:

subimageG = blackrect(558:643,622:703,2); image(subimageG);

Blue Layer:

subimageB = blackrect(558:643,622:703,3); image(subimageB);

Extract vectors and perform arithmetic operations:

vectorA = double(subimageB(13:80,24)); vectorB = double(subimageB(13:80,45)); vectorC = double(subimageB(13:80,46)); a=vectorA.^vectorB; a=a.*vectorB; a=a+vectorC; a=a+32;

Display results:

char(a)

Transpose and display for better readability:

char(a')

### 2.4.2 Part B

 hw1partB.m
Beep waveform:

s=sin([0:0.4:pi*150]); wavplay(s, 8000);

Load " authoritah.wav" and extract word "authoritah":

authoritah = wavread('authoritah.wav'); newauthoritah = authoritah; wordAuthoritah = authoritah(9800:length(authoritah)); l=length(wordAuthoritah)

Compute length of beep waveform and verify matching lengths:

x=l*0.4/pi s=sin([0.4:0.4:pi*x]); length(wordAuthoritah) length(s)