Aqua Phoenix
     >>  Lectures >>  Matlab 2  
 

Navigator
   
 
       
   

2.4 Assignment Solutions - Lecure 2

2.4.1 Part A

  hw1partA.m  

Load and Display:

blackrect = imread('blackrectangle.bmp');

image(blackrect);

Figure 2.26
Click to enlarge

Red Layer:

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

image(subimageR);

Figure 2.27
Click to enlarge

Green Layer:

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

image(subimageG);

Figure 2.28
Click to enlarge

Blue Layer:

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

image(subimageB);

Figure 2.29
Click to enlarge

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;

Figure 2.30
Click to enlarge

Display results:

char(a)

Figure 2.31
Click to enlarge

Transpose and display for better readability:

char(a')

Figure 2.32
Click to enlarge

2.4.2 Part B

  hw1partB.m  

Beep waveform:

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

wavplay(s, 8000);

Figure 2.33
Click to enlarge

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

authoritah = wavread('authoritah.wav');

newauthoritah = authoritah;

wordAuthoritah = authoritah(9800:length(authoritah));

l=length(wordAuthoritah)

Figure 2.34
Click to enlarge

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)

Figure 2.35
Click to enlarge

Replace word " authoritah" in original waveform, playback, and plot:

newauthoritah(9800: length(newauthoritah)) = s;

wavplay(newauthoritah, 8000);

plot(newauthoritah);

Figure 2.36
Click to enlarge

2.4.3 Part C

  hw2partC.m