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 image to enlarge, or click here to open
Red Layer:

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

Figure 2.27
Click image to enlarge, or click here to open
Green Layer:

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

Figure 2.28
Click image to enlarge, or click here to open
Blue Layer:

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

Figure 2.29
Click image to enlarge, or click here to open
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 image to enlarge, or click here to open
Display results:

char(a)

Figure 2.31
Click image to enlarge, or click here to open
Transpose and display for better readability:

char(a')

Figure 2.32
Click image to enlarge, or click here to open

2.4.2 Part B

  hw1partB.m  
Beep waveform:

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

Figure 2.33
Click image to enlarge, or click here to open
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 image to enlarge, or click here to open
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 image to enlarge, or click here to open
Replace word " authoritah" in original waveform, playback, and plot:

newauthoritah(9800: length(newauthoritah)) = s; wavplay(newauthoritah, 8000); plot(newauthoritah);

Figure 2.36
Click image to enlarge, or click here to open

2.4.3 Part C

  hw2partC.m