关键词不能为空

当前您在: 主页 > 英语 >

信号处理仿真(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的相关文章

  • 余华爱情经典语录,余华爱情句子

    余华的经典语录——余华《第七天》40、我不怕死,一点都不怕,只怕再也不能看见你——余华《第七天》4可是我再也没遇到一个像福贵这样令我难忘的人了,对自己的经历如此清楚,

    语文
  • 心情低落的图片压抑,心情低落的图片发朋友圈

    心情压抑的图片(心太累没人理解的说说带图片)1、有时候很想找个人倾诉一下,却又不知从何说起,最终是什么也不说,只想快点睡过去,告诉自己,明天就好了。有时候,突然会觉得

    语文
  • 经典古训100句图片大全,古训名言警句

    古代经典励志名言100句译:好的药物味苦但对治病有利;忠言劝诫的话听起来不顺耳却对人的行为有利。3良言一句三冬暖,恶语伤人六月寒。喷泉的高度不会超过它的源头;一个人的事

    语文
  • 关于青春奋斗的名人名言鲁迅,关于青年奋斗的名言鲁迅

    鲁迅名言名句大全励志1、世上本没有路,走的人多了自然便成了路。下面是我整理的鲁迅先生的名言名句大全,希望对你有所帮助!当生存时,还是将遭践踏,将遭删刈,直至于死亡而

    语文
  • 三国群英单机版手游礼包码,三国群英手机单机版攻略

    三国群英传7五神兽洞有什么用那是多一个武将技能。青龙飞升召唤出东方的守护兽,神兽之一的青龙。玄武怒流召唤出北方的守护兽,神兽之一的玄武。白虎傲啸召唤出西方的守护兽,

    语文
  • 不收费的情感挽回专家电话,情感挽回免费咨询

    免费的情感挽回机构(揭秘情感挽回机构骗局)1、牛牛(化名)向上海市公安局金山分局报案,称自己为了挽回与女友的感情,被一家名为“实花教育咨询”的情感咨询机构诈骗4万余元。

    语文