关键词不能为空

当前您在: 主页 > 英语 >

信号处理仿真(MATLAB)实验1-9

作者:高考题库网
来源:https://www.bjmy2z.cn/gaokao
2021-03-01 12:22
tags:

-

2021年3月1日发(作者:主犯)






信号处理仿真


(MATLAB)




实验指导书














青岛大 学自动化工程学院电子工程系


2011



4








MATLAB


实验一



一、实验目的:



1.



Be familiar with MATLAB Environment


2.



Be familiar with array and matrix


二、实验内容:



1.



Be familiar with Matlab 6.5



Startup Matlab 6.5, browse the major tools of the Matlab desktop


?



The Command Windows


?



The Command History Windows


?



Launch Pad


?



The Edit/Debug Window


?



Figure Windows


?



Workspace Browser and Array Editer


?



Help Browser


?



Current Directory Browser



PART I:


下列选择练习,不需提交实验报告



1




Give the answer of the following questions for the array



2


?


.


1


3


.


5


?


1


.


1


0


.

< br>0


?


6


?


0


.


0


1


.


1


?


?


3


.


4


6


.


6


2


.


8


?








a


r


r


a


1


y


?


?


?


2


.


1


0

< br>.


1


?


1


.


3


0


?


.


3


0


.


4


?


?


?


1


.


4


5


.


1


0


.


0

< br>1


.


1


?


?


0


.


0


1



What is the size of array1?


2



What is the value of array1(4,1)?


3



What is the size and value of array1(:,1:2)?


4




What is the size and value of array1([1 3], end)?



2




Give the answer of the following commad




1) a=1:2:5;





2) b=[a



a



a



];



3) c=b(1:2:3,1:2:3);



4) d=a+b(2,:)



5) w=[zeros(1,3) ones(3,1


)’


3:5



]



3




Give the answer of the sub- arrays




2

< br>?


.


1


3


.


5


?


1


.


1


0


.


0


?


6


?


0


.


0


1


.


1


?


?


3

< br>.


4


6


.


6


2


.


8


?









a


r


r


a


1


y


?


?


?


2


.


1


0

< br>.


1


?


1


.


3


0


?


.


3


0


.


4


?


?


?


1


.


4


5


.


1


0


.


0

< br>1


.


1


?


?


0


.


0


1 ) array1(3,:);



2) array1(:,3);



3) array1(1:2:3,[3 3 4])



4) array1([1 1],:)





1


4




Give the answer of the following operations



?


2








a


?


?


?


?


1


?


2


?


?


1


,

< br>b


?


?


2


?


?


?


0


?


?


1


?


?


1


?


?


?


,


d


?


?


,


c


2


?

< br>2


?


?


?



)


e


y


(


e


2










1) a+b




2) a*d



3)



a.*d



4) a*c



5)



a.*c




6)ab




7)



a.b



8)a.^b



EXERCISE II:



TEXT BOOK (4


TH




EDITION) PAGE 17-18:





1.1, 1.4, 1.7



2




MATLAB


实验二



一、实验目的:



1. Be familiar with array and matrix


2. Be familiar with MATLAB operations and simple plot function



PART I:


下列选择练习,不需提交实验报告



1



Edit & Run the m-file









% test step response function


wn=6;



kosi=[0.1:0.1:1.0 2];


figure(1);



hold on


for kos=kosi










num=wn^2; den=[1,2*kos*wn,wn.^2]; step(num,den)


end


hold off;


2



Edit & Run the m-file









% test plot function



x=0:pi/20:3*pi;



y1=sin(x);



y2=2*cos(2*x);



plot(x,y1,'rv:',x,y2,'bo--');


title('Plot



the Line of y=sin(2x) and its derivative');



xlabel('X



axis');



ylabel('Y


legend('f(x)','d/dx f(x)');



grid on;


3




Edit & Run the m-file









% test subplot and loglog function



x=0:0.1:10;



y=x.^2-10.*x+26;


subplot(2,2,1);



plot(x,y);



grid on;


subplot(2,2,2);



semilogx(x,y);



grid on;



subplot(2,2,3);



semilogy(x,y);



grid on;


subplot(2,2,4);



loglog(x,y);





grid on;


4



Edit & Run the m-file



% test max and plot function


volts=120;



rs=50;



rl=1:0.1:100;


amps=volts./(rs+rl);



pl=(amps.^2).*rl;



[maxvol,index]=max(pl);


plot(rl,pl,rl(index),pl(index),'rh'); grid on;


PART II:


下列选择练习,需提交实验报告



EXERCISE II:



TEXT BOOK (4


TH




EDITION) PAGE 69-73:





2.9 , 2.11, 2.13, 2.14




2.17 , 2.18






3


axis');




MATLAB


实验三



一、实验目的:



1.



Learn to design branch statements program



2.



Be familiar with relational and logical operators


3.



Practice 2D plotting



二、实验内容:



PART I: (


选择练习,不需提交实验报告


)



1. Hold command exercise


?



x=-pi:pi/20:pi;


?



y1=sin(x);



y2=cos(x);



plot(x,y1, 'b-');



hold on;


?




plot(x,y2, 'k--');



hold off;


?




legend ('sinx', 'cosx')


2. Figure command exercise



figure(1);


subplot(2,1,1);


x=-pi:pi/20:pi;



y=sin(x);



plot(x,y);



grid on;


title('Subplot 1 Title');


subplot(2,1,2);


x=-pi:pi/20:pi;



y=cos(x);



plot(x,y); grid on;


title('Subplot 2 Title');


3




Polar Plots exercise




g=0.5;




theta=0:pi/20:2*pi;




gain=2*g*(1+cos(theta));




polar(theta,gain,'r-');




title('fontsize{20} bfGain versus angle theta');




4. Assume that a,b,c, and d are defined, and evaluate the following expression.


a=20; b=-2; c=0; d=1;


(1) a>b; (2) b>d; (3) a>b&c>d; (4) a==b;



(5) a&b>c; 6) ~~b;


a=2;



b=[1



2;-0 10];



c=[0 1;2 0];



d=[-2 1 2;0 1 0];


(7)



~(a>b)



(8)



a>c&b>c



(9)



c<=d



a=2;



b=3;



c=10;



d=0;


(10) a*b^2>a*c



(11) d|b>a



(12) (d|b)>a


a=20;



b=-


2;



c=0;



d=’Test’;



(13) isinf(a/b)



(14) isinf(a/c)



(15)



a>b&ischar(d)



(16) isempty(c)


1


, where x is a number <1.


1


?


x


5.



Write a Matlab program to solve the function


y


(

< br>x


)


?


ln


4


Use an if structure to verify that the value passed to the program is legal. If the value of x is legal,


caculate y(x). If not ,write a suitable error message and quit.



PART II:



(


需提交实验报告


)



1. Write out m. file and plot the figures with grids


Assume that the complex function f(t) is defined by the equation


f(t)=(0.5-0.25i)t-1.0


Plot the amplitude and phase of function for


0


?


t


?


4 .



2. Write the Matlab statements required to calculate y(t) from the equation


?


?


3

< p>
t


2


?


5


t


?


0


y


(


t


)


?


?


2


?


5< /p>


3


t


t


?


0


?


for


value


of


t


between



9


and


9


in


steps


of


0.5.



Use


loops


and


branches


to


perform


this


calculation.


EXERCISE II:



TEXT BOOK (4


TH




EDITION) PAGE 121-124:




3.1




3.3 ,



3.5,



3.6,



3.7,



3.11,



3.14



5


MATLAB


实验四



一、实验目的:



1.



Learn to design loop statements program



2.



Be familiar with relational and logical operators


3.



Practice 2D plotting



二、实验内容:



PART I: (


选择练习,不需提交实验报告


)



4.



Compare the 3 approaches follows (Loops and Vectorization)


%A. Perform calculation by For Loop with pre-initialize array


tic;


?


square=zeros(1,10000)



%pre-initialize array


?


for ii=1:10000


?





square(ii)=ii^2;


?





square_root(ii)=ii^(1/2);


?





cube_root(ii)=ii^(1/3);


?


end


?


toc;



t1=toc


%B. Perform calculation by For Loop without



pre-initialize array


?


tic;


?




for ii=1:10000


?







square(ii)=ii^2;


?







square_root(ii)=ii^(1/2);


?







cube_root(ii)=ii^(1/3);


?




end


?




toc;



t2=toc


%C. Perform calculation with vectors


?


tic;


ii=1:10000


?







square(ii)=ii.^2;







square_root(ii)=ii.^(1/2);


cube_root(ii)=ii.^(1/3);


?


end


?


toc;


?


t3=toc


EXERCISE II:



TEXT BOOK (4


TH




EDITION) PAGE 165-171:



4.7




4.16




4.18




4.19




4.20




6


4.27



MATLAB


实验五




一、实验目的:



1.



Learn to write MATLAB functions


2.



Be familiar with complex data and character data


3.



Practice 2D plotting



二、实验内容:




1. Write three Matlab functions to calculate the hyperbolic sine, cosine, and





tangent functions:


e

< br>x


?


e


?


x











s


i


n


h


(


2


e


x


?


e


?


x


)


,


c

< br>o


s


h


(


2


e


x


?


e


?


x


h


)


?


,


t


x


a


n


?


x


(



e


?

< br>e


)


then


plot


the


shapes


of


hyperbolic


sine,


cosine,


and


tangent


functions


on


one


figure,


?


5


?


x


?


5


.


2. Write a program use the function


f

< p>
(


x


)


?


x


3


?


5

x


2


?


5


x


?


2



and plot the line,



and search for the minimum and maximum in 200 steps over the range of


?


1


?


x


?

3


,



mark


the minimum and maximum on the line figure.





3.


Write


a


function


to


calculate


the


distance


between


two


points


(

< p>
x


1


,


y


1


)



and



(


x


2


,


y


2


)


,


that


the


points


should be given by



input



function.



4.


Write


a


function


complex_to



that


accept


a


complex


number


var


,


and


returns


two


output


arguments containing the magnitude


mag


and angle


theta


of the complex number. The output


angle should be in degrees.





Write another function


polar_to_complex


that accepts two input arguments containing the


magnitude


mag


and angle


theta


of the complex number in degrees, and returns the complex


number


var


.


4.



Write a program that accepts a series of strings from a user with the input function, sorts


the strings into ascending order, and prints them out.


EXERCISE II:



TEXT BOOK (4


TH




EDITION) PAGE 213-223




5.10




5.11




5.19




5.25




5.26




5.33




7




MATLAB


实验六



一、实验目的:



1.



Learn to write MATLAB functions


2.



Be familiar with complex data and character data


5.



Practice 2D plotting



二、实验内容:




1. Write three Matlab functions to calculate the hyperbolic sine, cosine, and





tangent functions:


e

< br>x


?


e


?


x











s


i


n


h


(


2


e


x


?


e


?


x


)


,


c

< br>o


s


h


(


2


e


x


?


e


?


x


h


)


?


,


t


x


a


n


?


x


(



e


?

< br>e


)


then


plot


the


shapes


of


hyperbolic


sine,


cosine,


and


tangent


functions


on


one


figure,


?


5


?


x


?


5


.


2. Write a program use the function


f

< p>
(


x


)


?


x


3


?


5

x


2


?


5


x


?


2



and plot the line,



and search for the minimum and maximum in 200 steps over the range of


?


1


?


x


?

3


,



mark


the minimum and maximum on the line figure.





3.


Write


a


function


to


calculate


the


distance


between


two


points


(

< p>
x


1


,


y


1


)



and



(


x


2


,


y


2


)


,


that


the


points


should be given by



input



function.



4.


Write


a


function


complex_to



that


accept


a


complex


number


var


,


and


returns


two


output


arguments containing the magnitude


mag


and angle


theta


of the complex number. The output


angle should be in degrees.





Write another function


polar_to_complex


that accepts two input arguments containing the


magnitude


mag


and angle


theta


of the complex number in degrees, and returns the complex


number


var


.


5.



Write a program that accepts a series of strings from a user with the input function, sorts the


strings into ascending order, and prints them out.


EXERCISE II:



TEXT BOOK (4


TH




EDITION) PAGE 265-267:




6.2




6.10




6.11




8


MATLAB


实验七



一、实验目的:



1. Practice 2D plotting and 3D plotting


2. Learn to use fplot function


3. Be familiar with cell arrays and structure arrays



二、实验内容:



1.


Give


the


3D


plot


figure


of


x


(


t


)


?


e


?


0.3


t


sin(3


t


)


,


y


(


t


)


?


e


?


0.1


t


cos (


t


)



use


plot3


function,


0


?

< p>
x


?


20


, and grid on, linewidth is 3.0.




2. Plot the function


y


?


e


?


x

< br>sin


x


,


0


?


x


?


2

, step 0.1. Create the following plot types: (a) stem


plot;



(b) stair plot;



(c) bar plot;



(d) compass plot.




3. Plot the function


f


(


x

< p>
)


?


1/


x



over the range


0.1


?


x


?


10.0



using





function fplot, and


grid on.



4. Create a cell arrays:





5. Create a structure arrays and to calculate the mean billing of three patients:




9


MATLAB


实验八




一、实验目的:



Be familiar with Input/Output functions



二、实验内容:




1.


Write


a


m-file.


The


m-file


creates


an


array


containing


1


?


50



random


values,


sorts


the


array


into


ascending


order,


opens


a


user-specified


file


for


writing


only,


then


writes


the


array to disk in 32-bit floating-point format , and close the file. It then opens the file and


read the data back into


5


?


10



array.


2.


Edit


a


file


as


data4_


that


contains


4


?


4



square


matrix,


then


import


the


array


use


uiimport


function, and calculate the inverse of the square matrix .





3.



Write a program to read a set of integers from an input data file, and locate the largest and


smallest values within the data file. Print out the largest and smallest values, together with


the lines on which they were found in one figure.





10


MATLAB


实验九




一、实验目的:



1.



Be familiar with sound file


2.



Learn about create sound and use speaker.


3.



Making Music with MATLAB




二、实验内容:





Before


we


actually


start


making


music,


let's


revise


a


few


AC


waveform


basics.


Consider


the


sine


wave


shown in the figure below:



The sine wave shown here can be described mathematically as:


v = A


sin


2


?


f t


where A is the Amplitude (varying units), f is the frequency (Hertz) and t is the time (seconds).


T is known as the time period (seconds) and T=1/f


Based on the equation,


when t=0; v = A


sin


2


?


f(0) = 0


when t=T/4; v = A


sin


2


?


f (T/4) = A


sin


2


?


f(1/4f) = A


sin


(


?????????



when t=T/2; v = A


sin


2


?


f (T/2) = A


sin


2


?


f(1/2f) = A


sin


(


???????



and so on.



Sound waves are created when a waveform as shown here is used to vibrate molecules in a material medium


at audio frequencies (300 Hz <= f <= 3 kHz).


If you wish to create a waveform such as the one shown in the figure, you would need to evaluate the function,


v = A


sin


2


?


f t, at discrete times, t (shown as the time instants of the red dots), typically at equal time intervals.


These time intervals must be


to obtain a


This time interval is called the


specifying it only at discrete points in time is called sampling. (you should already know much of this stuff from


the previous Clinic on Data Acquisition Basics).



11


The sampling interval, shown here is T


s


; corresponding to that there exists a


s


.


As an example, the MATLAB code to create a sine wave of amplitude A = 1, at audio frequency of 466.16


Hz (corresponds to A# in the Equal Tempered Chromatic Scale) would be:


>>


v = sin(2*pi*466.16*[0:0.000125:1.0]);



The vector,


v


, now contains samples of the sine wave, starting at t=0 s, to t=1.0 s, in samples spaced 0.000125 s


apart (the sampling interval T


s


). This corresponds to a sampling frequency of 8 KHz, which is standard for voice


grade audio channel.


Now, you can either plot this sine wave; or you can hear it!!!


To plot, simply do


>>


plot(v);



To hear


v


, you need to convert the data contained in


v


to some standard audio format that can be played using a


Sound


Card


and


Speakers


on


your


PC.


One


such


standard


audio


format


is


called


the



format.


Matlab


provides


a


function


called


wavwrite



to


convert


a


vector


into


wav


format


and


save


it


on


disk.


Do


>>


help


wavwrite


for more details. Now, to create a wav file, do


>>


wavwrite(v, '')


;


(you can give any file name between the ' ' s)



Now, you can


the


Sound Recorder


program.


Start


this


by


pointing


to


Start


-


Programs


-


Accessories


-


Multimedia


-


Sound


Recorder. Open the wav file using the File Menu and press Play. If you have installed a sound card and a pair of


speakers on your PC, you should be able to hear a short note.


Now that you can make a single note, you can put notes together and make music!!!


Let's look at the following piece of music:


A A E E F# F# E E


D D C#C# B B A A


E E D D C# C# B B (repeat once)


(repeat first two lines once)


The American Standard Pitch for each of this notes is:


A: 440.00 Hz


B: 493.88 Hz


C#: 554.37 Hz


D: 587.33 Hz


E: 659.26 Hz


F#: 739.99 Hz


Assuming each note lasts for 0.5 seconds, the MA


TLAB m-file for creating a wav file for this piece of music


would be:


clear;



a=sin(2*pi*440*(0:0.000125:0.5));



b=sin(2*pi*493.88*(0:0.000125:0.5 ));



cs=sin(2*pi*554.37*(0:0. 000125:0.5));



d=sin(2*pi*587 .33*(0:0.000125:0.5));



e=sin (2*pi*659.26*(0:0.000125:0.5));



fs=sin(2*pi*739.99*(0:0.000125:0.5));


line1=[a,a,e,e,fs,fs,e,e,];



line2=[d,d,cs,cs,b,b,a,a,];



line3=[e,e,d,d,cs,cs,b,b];


< /p>


song=[line1,line2,line3,line3,line1,line 2];



wavwrite(song,'');




12


HINT


:


Before


you


code


the


entire


song,


just


code


the


first


line,


create


a


wav


file,


play


it


and


make


sure


everything works.



MATLAB


实验十


-


十六





13







14







15








16




17








18










19




20










21





22










23








24







25






26






27




28



29



30

-


-


-


-


-


-


-


-



本文更新与2021-03-01 12:22,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/688263.html

信号处理仿真(MATLAB)实验1-9的相关文章

  • 爱心与尊严的高中作文题库

    1.关于爱心和尊严的作文八百字 我们不必怀疑富翁的捐助,毕竟普施爱心,善莫大焉,它是一 种美;我们也不必指责苛求受捐者的冷漠的拒绝,因为人总是有尊 严的,这也是一种美。

    小学作文
  • 爱心与尊严高中作文题库

    1.关于爱心和尊严的作文八百字 我们不必怀疑富翁的捐助,毕竟普施爱心,善莫大焉,它是一 种美;我们也不必指责苛求受捐者的冷漠的拒绝,因为人总是有尊 严的,这也是一种美。

    小学作文
  • 爱心与尊重的作文题库

    1.作文关爱与尊重议论文 如果说没有爱就没有教育的话,那么离开了尊重同样也谈不上教育。 因为每一位孩子都渴望得到他人的尊重,尤其是教师的尊重。可是在现实生活中,不时会有

    小学作文
  • 爱心责任100字作文题库

    1.有关爱心,坚持,责任的作文题库各三个 一则150字左右 (要事例) “胜不骄,败不馁”这句话我常听外婆说起。 这句名言的意思是说胜利了抄不骄傲,失败了不气馁。我真正体会到它

    小学作文
  • 爱心责任心的作文题库

    1.有关爱心,坚持,责任的作文题库各三个 一则150字左右 (要事例) “胜不骄,败不馁”这句话我常听外婆说起。 这句名言的意思是说胜利了抄不骄傲,失败了不气馁。我真正体会到它

    小学作文
  • 爱心责任作文题库

    1.有关爱心,坚持,责任的作文题库各三个 一则150字左右 (要事例) “胜不骄,败不馁”这句话我常听外婆说起。 这句名言的意思是说胜利了抄不骄傲,失败了不气馁。我真正体会到它

    小学作文