信号处理仿真MATLAB实验16.docx
- 文档编号:9977132
- 上传时间:2023-02-07
- 格式:DOCX
- 页数:24
- 大小:227.85KB
信号处理仿真MATLAB实验16.docx
《信号处理仿真MATLAB实验16.docx》由会员分享,可在线阅读,更多相关《信号处理仿真MATLAB实验16.docx(24页珍藏版)》请在冰豆网上搜索。
信号处理仿真MATLAB实验16
信号处理仿真(MATLAB)
实验指导书
青岛大学自动化工程学院电子工程系
2006年4月
MATLAB实验一
一、实验目的:
1.BefamiliarwithMATLABEnvironment
2.Befamiliarwitharrayandmatrix
3.BefamiliarwithMATLABoperationsandsimpleplotfunction
二、实验内容:
1.BefamiliarwithMatlab6.5
StartupMatlab6.5,browsethemajortoolsoftheMatlabdesktop
⏹TheCommandWindows
⏹TheCommandHistoryWindows
⏹LaunchPad
⏹TheEdit/DebugWindow
⏹FigureWindows
⏹WorkspaceBrowserandArrayEditer
⏹HelpBrowser
⏹CurrentDirectoryBrowser
PARTI:
下列选择练习,不需提交实验报告
1.Givetheanswerofthefollowingquestionsforthearray
1)Whatisthesizeofarray1?
size(array)45
2)Whatisthevalueofarray1(4,1)?
3)Whatisthesizeandvalueofarray1(:
1:
2)?
1.10000
01.1000
2.10000.1000
-1.40005.1000
4)Whatisthesizeandvalueofarray1([13], end)?
6.0000
1.3000
2.Givetheanswerofthefollowingcommad
1)a=1:
2:
5;
a=135
2)b=[a’a’a’];
b=
111
333
555
3)c=b(1:
2:
3,1:
2:
3);
c=11
55
4)d=a+b(2,:
)
d=468
5)w=[zeros(1,3) ones(3,1)’ 3:
5’]
w=000111345
3.Givetheanswerofthesub-arrays
1)array1(3,:
);2.10000.10000.3000-0.40001.3000
2)array1(:
3);2.1000
-6.6000
0.3000
0
3)array1(1:
2:
3,[334])
2.10002.1000-3.5000
0.30000.3000-0.4000
4)array1([11],:
)
1.100002.1000-3.50006.0000
1.100002.1000-3.50006.0000
4.Givetheanswerofthefollowingoperations
1)a+b
3-3
-14
2)a*d2-2
-12
3)a.*d20
02
4)a*c6
-5
5)a.*cwrong
6)a\b
1.00001.0000
0.50001.5000
7)a.\b
0.50000.5000
01.0000
8)a.^b
2.0000-0.5000
1.00004.0000
PARTI:
下列选择练习,不需提交实验报告
1.Edit&Runthem-file
%teststepresponsefunction
wn=6;kosi=[0.1:
0.1:
1.02];
figure
(1);holdon
forkos=kosi
num=wn^2;den=[1,2*kos*wn,wn.^2];step(num,den);step阶跃响应num分子den分母适量矩阵
end
holdoff;
2.Edit&Runthem-file
%testplotfunction
x=0:
pi/20:
3*pi;y1=sin(x);y2=2*cos(2*x);plot(x,y1,'rv:
',x,y2,'bo--');
title('PlottheLineofy=sin(2x)anditsderivative');xlabel('Xaxis');ylabel('Yaxis');
legend('f(x)','d/dxf(x)');gridon;
3.Edit&Runthem-file
%testsubplotandloglogfunction
x=0:
0.1:
10;y=x.^2-10.*x+26;
subplot(2,2,1);plot(x,y);gridon;
subplot(2,2,2);semilogx(x,y);gridon;
subplot(2,2,3);semilogy(x,y);gridon;
subplot(2,2,4);loglog(x,y);gridon;
4.Edit&Runthem-file
%testmaxandplotfunction
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');gridon;
MATLAB实验二
一、实验目的:
1.Learntodesignbranchstatementsprogram
2.Befamiliarwithrelationalandlogicaloperators
3.Practice2Dplotting
二、实验内容:
PARTI:
(选择练习,不需提交实验报告)
1.Holdcommandexercise
x=-pi:
pi/20:
pi;
y1=sin(x);y2=cos(x);plot(x,y1,'b-');holdon;
plot(x,y2,'k--');holdoff;
legend('sinx','cosx')
2.Figurecommandexercise
figure
(1);
subplot(2,1,1);
x=-pi:
pi/20:
pi;y=sin(x);plot(x,y);gridon;
title('Subplot1Title');
subplot(2,1,2);
x=-pi:
pi/20:
pi;y=cos(x);plot(x,y);gridon;
title('Subplot2Title');
3.PolarPlotsexercise
g=0.5;
theta=0:
pi/20:
2*pi;
gain=2*g*(1+cos(theta));
polar(theta,gain,'r-');
title('\fontsize{20}\bfGainversusangle\theta');
4.Assumethata,b,c,anddaredefined,andevaluatethefollowingexpression.
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;-010];c=[01;20];d=[-212;010];
(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)
5.WriteaMatlabprogramtosolvethefunction
wherexisanumber<1.Useanifstructuretoverifythatthevaluepassedtotheprogramislegal.Ifthevalueofxislegal,caculatey(x).Ifnot,writeasuitableerrormessageandquit.
PARTII:
(需提交实验报告)
1.
3.Writeoutm.fileandplotthefigureswithgrids
Assumethatthecomplexfunctionf(t)isdefinedbytheequation
f(t)=(0.5-0.25i)t-1.0
Plottheamplitudeandphaseoffunctionfor
t=0:
0.1:
4;
ft=(0.5-0.25i)*t-1.0;
amp=abs(ft);
phase=angle(ft);
subplot(211);
plot(amp,t);
title('ft的幅度相位图')
xlabel('taxis');ylabel('ft幅度axis');
gridon
subplot(212);
plot(phase,t);
xlabel('taxis');ylabel('ft相位axis');
gridon
4.WritetheMatlabstatementsrequiredtocalculatey(t)fromtheequation
forvalueoftbetween–9and9instepsof0.5.Useloopsandbranchestoperformthiscalculation.
5.Homework:
需提交实验报告
Seethetextbookpage73:
2.12,2.13,2.15,2.16
MATLAB实验三
一、实验目的:
1.Learntodesignloopstatementsprogram
2.Befamiliarwithrelationalandlogicaloperators
3.Practice2Dplotting
二、实验内容:
PARTI:
(选择练习,不需提交实验报告)
4.Comparethe3approachesfollows(LoopsandVectorization)
%A.PerformcalculationbyForLoopwithpre-initializearray
tic;
square=zeros(1,10000)%pre-initializearray
forii=1:
10000
square(ii)=ii^2;
square_root(ii)=ii^(1/2);
cube_root(ii)=ii^(1/3);
end
toc;t1=toc
%B.PerformcalculationbyForLoopwithoutpre-initializearray
tic;
forii=1:
10000
square(ii)=ii^2;
square_root(ii)=ii^(1/2);
cube_root(ii)=ii^(1/3);
end
toc;t2=toc
%C.Performcalculationwithvectors
tic;
ii=1:
10000
square(ii)=ii.^2;
square_root(ii)=ii.^(1/2);
cube_root(ii)=ii.^(1/3);
end
toc;t3=toc
Homework:
需提交实验报告
Page131:
3.2,3.4,3.8,3.11
MATLAB实验四
一、实验目的:
1.LearntowriteMATLABfunctions
2.Befamiliarwithcomplexdataandcharacterdata
3.Practice2Dplotting
二、实验内容:
Derivativeofafunction.
1.WritethreeMatlabfunctionstocalculatethehyperbolicsine,cosine,and
tangentfunctions:
thenplottheshapesofhyperbolicsine,cosine,andtangentfunctionsononefigure,
.
2.Writeaprogramusethefunction
andplottheline,
andsearchfortheminimumandmaximumin200stepsovertherangeof
marktheminimumandmaximumonthelinefigure.
3.Writeafunctiontocalculatethedistancebetweentwopoints
and
thatthepointsshouldbegivenby‘input’function.
4.Writeafunctioncomplex_tothatacceptacomplexnumbervar,andreturnstwooutputargumentscontainingthemagnitudemagandanglethetaofthecomplexnumber.Theoutputangleshouldbeindegrees.
Writeanotherfunctionpolar_to_complexthatacceptstwoinputargumentscontainingthemagnitudemagandanglethetaofthecomplexnumberindegrees,andreturnsthecomplexnumbervar.
4.Writeaprogramthatacceptsaseriesofstringsfromauserwiththeinputfunction,sortsthestringsintoascendingorder,andprintsthemout.
Derivativeofafunction.Thederivativeofacontinuousfunctionf(x)isdefinedbytheequation
Inasampledfunction,thisdefinitionbecomes
where
Homeworks:
需提交实验报告
Page181:
4.15,4.16,4.19,4.20,4.27
MATLAB实验五
一、实验目的:
1.Befamiliarwithcomplexdataandcharacterdata
2.ractice2Dplotting
二、实验内容:
1.WritethreeMatlabfunctionstocalculatethehyperbolicsine,cosine,and
tangentfunctions:
thenplottheshapesofhyperbolicsine,cosine,andtangentfunctionsononefigure,
.
2.Writeaprogramusethefunction
andplottheline,
andsearchfortheminimumandmaximumin200stepsovertherangeof
marktheminimumandmaximumonthelinefigure.
3.Writeafunctiontocalculatethedistancebetweentwopoints
and
thatthepointsshouldbegivenby‘input’function.
4.Writeafunctioncomplex_tothatacceptacomplexnumbervar,andreturnstwooutputargumentscontainingthemagnitudemagandanglethetaofthecomplexnumber.Theoutputangleshouldbeindegrees.
Writeanotherfunctionpolar_to_complexthatacceptstwoinputargumentscontainingthemagnitudemagandanglethetaofthecomplexnumberindegrees,andreturnsthecomplexnumbervar.
5.Writeaprogramthatacceptsaseriesofstringsfromauserwiththeinputfunction,sortsthestringsintoascendingorder,andprintsthemout.
Homeworks:
需提交实验报告
Page181:
5.8,5.10,5.14,5.16,5.17,5.22,5.24
MATLAB实验六
一、实验目的:
1.Practice2Dplottingand3Dplotting
2.Learntousefplotfunction
3.Befamiliarwithcellarraysandstructurearrays
二、实验内容:
1.Givethe3Dplotfigureof
useplot3function,
andgridon,linewidthis3.0.
t=-10:
0.1:
10;
x=exp(-0.3*t).*sin(3*t);
y=exp(-0.1*t).*cos(t);
plot3(x,y,t,'linewidth',3);gridon
xlabel('x')
ylabel('y')
zlabel('z')
2.Plotthefunction
step0.1.Createthefollowingplottypes:
(a)stemplot;(b)stairplot;(c)barplot;(d)compassplot.
x=0:
0.1:
2;
y=exp(-x).*sin(x);
subplot(221);stem(x,y);
subplot(222);stairs(x,y);
subplot(223);bar(x,y);
subplot(224);compass(x,y);
3.Plotthefunction
overtherange
usingfunctionfplot,andgridon.
functiony=myfun(x)
y=1./sqrt(x);
fh=@myfun;
fplot(fh,[020]);gridon
4.Createacellarrays:
a={[143;058;729],'annesmith',3+7i;5-2i,-3.14,[];3.14,[],5}
a=
[3x3double]'annesmith'[3.0000+7.0000i]
[5.0000-2.0000i][-3.1400][]
[3.1400][][5]
5.Createastructurearraysandtocalculatethemeanbillingofthreepatients:
Homeworks:
需提交实验报告
Page285:
6.4,6.9,6.11
MATLAB实验七
一、实验目的:
BefamiliarwithInput/Outputfunctions
二、实验内容:
1.Writeam-file.Them-filecreatesanarraycontaining
randomvalues,sortsthearrayintoascendingorder,opensauser-specifiedfileforwritingonly,thenwritesthearraytodiskin32-bitfloating-pointformat,andclosethefile.Itthenopensthefileandreadthedatabackinto
array.
2.Editafileasdata4_4.txtthatcontains
squarematrix,thenimportthearrayuseuiimportfunction,andcalculatetheinverseofthesquarematrix.
3.
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 信号 处理 仿真 MATLAB 实验 16