Worksheet22201.docx

上传人:b****6 文档编号:6094241 上传时间:2023-01-03 格式:DOCX 页数:34 大小:299.67KB
下载 相关 举报
Worksheet22201.docx_第1页
第1页 / 共34页
Worksheet22201.docx_第2页
第2页 / 共34页
Worksheet22201.docx_第3页
第3页 / 共34页
Worksheet22201.docx_第4页
第4页 / 共34页
Worksheet22201.docx_第5页
第5页 / 共34页
点击查看更多>>
下载资源
资源描述

Worksheet22201.docx

《Worksheet22201.docx》由会员分享,可在线阅读,更多相关《Worksheet22201.docx(34页珍藏版)》请在冰豆网上搜索。

Worksheet22201.docx

Worksheet22201

MatlabWorksheet2

PartA(In-classroomexercises)

1.Usingplottodisplaythefollowingvoltagewithappropriatelinetype,titleandlabels.Alsopresentthegraphwithsuitablerangesofaxis.

wheref=50Hz.

(Hint:

timeintervalmustbesmallenough,e.g.0.001seconds.Therefore,t=0:

0.001:

1isappropriate);

ANSWER:

t=0:

0.001:

1;

v=220*sin(2*pi*50*t);

plot(t,v);

2.Usingplottodisplaythefollowingvoltagewithappropriatelinetype,titleandlabels.Alsopresentthegraphwithsuitablerangesofaxis.

wheref=50Hz.

Inaddition,onthesamegraph,drawtheenvelopeoftheoscillationandaddlegends.

ANSWER:

v2=220.*exp(-5.*t).*sin(2*pi*50.*t);

plot(t,v2);

legend('curve')

title('Graphofv2=220.*exp(-5.*t).*sin(2*pi*50.*t)')

xlabel('taxis')

ylabel('v-axis')

gridon

3.Usesubplot,drawa2by2arrayofplotsforthefollowingfunctions:

ANSWER:

Applyappropriatelinetype,title,labelsandaxisrangesforthegraphs.

v_1=cos(10*pi*t);

subplot(2,2,1);

plot(t,v_1);

xlabel('t'),ylabel('v1')

title('Graphofv_1=cos(10*pi*t)')

v_2=cos(10*pi*t).*exp(-5*t);

subplot(2,2,2);

plot(t,v_2);

xlabel('t'),ylabel('v2')

title('Graphofv_2=cos(10*pi*t).*exp(-5*t)')

v_3=cos(10*pi*t).*exp(-10*t);

subplot(2,2,3);

plot(t,v_3);

xlabel('t'),ylabel('v3')

title('Graphofv_3=cos(10*pi*t).*exp(-10*t)')

v_4=cos(10*pi*t).*exp(-20*t);

subplot(2,2,4);

plot(t,v_4);

xlabel('t'),ylabel('v4')

title('Graphofv_4=cos(10*pi*t).*exp(-20*t)')

 

4.Useplot3toplot2spiralcurveslikebelowwithappropriatelinewidthandcolour.

ANSWER:

t=0:

0.001:

10;

z=0.2*t;

x=sin(2*pi.*t).*z.*z;

y=cos(2*pi.*t).*z.*z;

plot3(x,y,z,'g','LineWidth',2);

holdon;

axis([-44-4402]);

holdoff;

z1=z.^0.5

x1=sin(2*pi.*t).*(z1)

y1=cos(2*pi.*t).*(z1)

plot3(x1,y1,z1,'r','LineWidth',2);

5.Displaythesurfaceusingmeshandcontourwithasuitableresolution:

ANSWER:

[x,y]=meshgrid(-2:

.1:

2,-2:

.2:

2);

f=exp(-0.005.*((x-50).^2+(y-50).^2));

figure

(1);

mesh(x,y,f);xlabel('x');ylabel('y');grid;

figure

(2);contour(x,y,f);

xlabel('x');ylabel('y');grid;

6.Load2ofyourphotosintoMatlabWorkSpaceusingimread.a)Changebrightnesslocallyorglobally.b)Overlapthemtoproduceanewphoto.c)writeanewphotointoafileusingimwrite.(Note:

lowerversionofMatlabsuchas6.5isnotallowedtodosomedirectimageoperations.)

ANSWER:

A=imread('11.jpg');

B=imread('22.jpg');

[MNP]=size(A);

imshow(A+100);

figure

(1);

C=A+B(1:

M,1:

N,1:

P);

imshow(C);

figure

(2);

imwrite(C,'33.jpg');

 

7.

theequationcoefficients:

A=[1-143

-545-6

07-89

-13-26];(M=N)

a)FindthedeterminantofA,

b)FindtheinverseofAandcheckformatrixsingularity,

c)IfB=[5;1;-2;3],findtheunknownxintheequation.

ANSWER:

a)det(A)

ans=

-765.0000

b)inv(A)

ans=

0.3333-0.00000.3333-0.6667

0.20000.11760.2706-0.3882

0.20000.05880.0353-0.0941

0.0222-0.0392-0.06800.2183

cond(A)

ans=

16.4186

c)x=inv(A)*b

ans=

-1.0000

-0.5882

0.7059

0.8627

8.Forlinearsimultaneousequations,

M>N,theequationcoefficients:

A=[1-143

-545-6

07-89

-13-26

1-253

147-3];

a)FindthedeterminantofA’*A,

b)FindtheinverseofA’*Aandcheckformatrixsingularity,

c)IfB=[5;1;-2;3;4;0],findthesolutionoftheequation.

ANSWER:

a)det(A'*A)

ans=

2.1051e+07

b)inv(A'*A)

ans=

0.08840.0321-0.0013-0.0219

0.03210.02310.0002-0.0099

-0.00130.00020.00850.0053

-0.0219-0.00990.00530.0144

cond(A'*A)

ans=

32.5278

c)x=inv(A'*A)*A'*B

x=

-0.8903

-0.4898

0.5755

0.7083

9.Dataof10recordsareshownbelow

y=[3.54.33.75.46.67.38.78.89.49.010.012.011.39.913.3],

Usepolyfitwithdifferentorders(from1to3)ofpolynomialstofindacurveofbestfit.Checkthetotaldistancebetweenthefittedcurvezandrecordsdefinedby

.

ANSWER:

x=linspace(0,1,15);

y=[3.54.33.75.46.67.38.78.89.49.010.012.011.39.913.3];

plot(x,y,'x');

holdon;

p=polyfit(x,y,1);

z=polyval(p,x);

s1=sqrt(sum((z-y).^2));%totaldistance

plot(x,z,'b','LineWidth',3);

holdon;

%一次拟合

p=polyfit(x,y,2);

z=polyval(p,x);

s2=sqrt(sum((z-y).^2));%totaldistance

plot(x,z,'r','LineWidth',3);

holdon;

%二次拟合

p=polyfit(x,y,3);

z=polyval(p,x);

s3=sqrt(sum((z-y).^2));%totaldistance

plot(x,z,'g','LineWidth',3);

%三次拟合

holdoff;

gridon;

s1=

3.2807

s2=

3.0399

s3=

3.0398

10.Createasetof20pointsfromacurvebyMatlabcode:

x=1:

20;y=2*exp(-0.3*(x-5).^2)+0.7*exp(-0.2*(x-12).^2);

Theninterpolatethecurveto60pointsusing‘linear’and‘spline’options,respectively.Seethequalityofdifferenttypesofinterpolation.

ANSWER:

xi=1:

0.25:

20;

yi=interp1(x,y,xi,'linear');

plot(x,y,'r*');holdon;

plot(xi,yi,'o');

plot(xi,yi,':

');

holdoff;

yi=interp1(x,y,xi,'spline');

figure

(2);

plot(x,y,'r*');holdon;

plot(xi,yi,'o');

plot(xi,yi,':

');

holdoff;

 

PartB

1.Usingtheplotandsubplotfunctionscreate4plotsona2by2arrayofsubplots,forthefunctionexp(-t)sin(5t)showingineachplotthefunctioninthecorrespondingintervalsofti.e.(-2,-1),(-1,0),(0,1)and(1,2).

Answer:

t=-2:

.01:

2;

x=exp(-t).*sin(5.*t);

subplot(2,2,1);

plot(t,x);axis([-2,-1-2020]);

subplot(2,2,2);

plot(t,x);axis([-1,0-2020]);

subplot(2,2,3);

plot(t,x);axis([0,1-2020]);

subplot(2,2,4);

plot(t,x);axis([1,2-2020]);

2.Athreephaseinductionmotorcharacteristicisgivenintermsofmechanicalshaftoutputtorque

(NMNewton-meter)asafunctionofrotationalspeedω(rad/sradianpersecond).Thisisapproximatedby3piece-wiselinearequationsasfollows:

Thismotorisdirectlycoupledtoaload

whichcanberepresentedas

Write2separateMatlabfunctionm-filesinwhich:

a)themotorcharacteristic,b)theloadcharacteristicaredefinedonlyasfunctionsofω.Namethemmotor.mandsysload.m,respectively.

Answer:

w=0:

0.01:

120*pi;

a)Tm=(w>=0&w<=90*pi).*w*(90*pi)+4+(w<=110*pi&w>90*pi).*(-10*w/(pi)+1200)+(w>110*pi&w<=120*pi).*(-10*w/(pi)+1200);

plot(w,Tm);

b)Tl=-50*(w/(120*pi)).^3+100*(w/(120*pi)).^2+4*w./(120*pi);

3.WriteaMatlabscripgt-mfilewhichcallsyourfunctionm-filesfromQuestion2.Andplotthemotorandloadcharactersticsonthesamefigure,givingsuitablelabellingandtitle.Namethisscriptm-filesystemplot.m

Answer:

w=0:

pi/20:

120*pi;

plot(w,Tm,'m','LineWidth',2); hold on; 

plot(w,Tl,'r','LineWidth',2); hold off; 

xlabel('speed w(rad/s_)'); 

ylabel('torque(NM Newton-meter)'); 

title('the motor and load characterstics'); 

legend('motor line','sysload line')

4.Writeasriptm-filewhichfindsallthemathematicallpossiblepoints(valuesofω)where

5.

fortherange0≤ω≤120π(rad/s)withthecharacteristicgiveninQuestion2.Thesystemcouldtheoreticallyoperateataspeedωwhere

Mathematically,thisinvolvesfindingtherootsoftheequation

Giveanametothism-fileposspoints.m.Callposspoints.minsystemplot.mandshowallofthepointsonasystemplotusingthe‘o’symbol.

Answer:

function[Tm]=tm(w)

Tm=(w>=0&w<=90*pi).*w*(90*pi)+4+(w<=110*pi&w>90*pi).*(-10*w/(pi)+1200)+(w>110*pi&w<=120*pi).*(-10*w/(pi)+1200);

end;

Function[T1]=t1(w)

Tl=-50*(w/(120*pi)).^3+100*(w/(120*pi)).^2+4*w./(120*pi);

end   

(2)x

(1)=fzero(@tm,[60,90]); x

(2)=fzero(@tm,[300,320]); x(3)=fzero(@tm,[350,370]);   

 

(3)w=0:

pi/20:

120*pi; Tm=tm(w); 

plot(w,Tm,'m','LineWidth',2); hold on; 

Tl=t1(w); 

plot(w,Tl,'r','LineWidth',2); hold on; 

xlabel('speed w(rad/s_)'); 

ylabel('torque(NM Newton-meter)'); 

title('the motor and load characterstics'); legend('motor line','sysload line') posspoints; 

Tl=-50*(x/(120*pi)).^3+100*(x/(120*pi)).^2+4*x/(120*pi) plot(x,Tl,'ko','LineWidth',2); hold off; grid on; 

 

PartC

IntroductiontoDSP

1.Basicdigitalsignals

Unitimpulsefunction

Exercise1-1:

DisplaytheunitimpulsefunctionwithMatlabcode.ThecodecanbeeithertypedunderMatlabpromptorwrittenintoascriptMatlabfile,thenrunthefile.

n=-10:

10;

fork=1:

21

x(k)=0;

end;

x(11)=1;

stem(n,x);

axis([-101002]);

Problem1-1:

Forthesignal

writetheMatlabcodeandcopytheresultfigureintothefollowingboxes.

 

n=-10:

10;

fork=1:

21

x(k)=0;

end;

x(9)=2;

stem(n,x);

axis([-101002]);

 

Unitstepfunction

Exercise1-2:

DisplaytheunitstepfunctionwithMatlabcode:

n=-10:

10;

fork=1:

10

x(k)=0;

end;

 

fork=11:

21

x(k)=1;

end;

stem(n,x);

axis([-101002]);

Problem1-2:

Forthesignal

writetheMatlabcode,anddisplaythecorrespondingsignalintothefollowingboxes.

 

n=-10:

10;

fork=1:

12

x(k)=0;

end;

fork=13:

21

x(k)=-1;

end;

stem(n,x);

axis([-1010-21]);

Sinewave

where-frequency(rad/second),T-samplinginterval(seconds)

Exercise1-3:

LetT=0.02,=6.28.Usingthefollowingcode,plotonthescreenintheregion0n100.

n=0:

100;

T=0.02;

omega=6.28;

fork=1:

101

x(k)=sin((k-1)*omega*T);

end;

stem(n,x);

Exercise1-3:

LetT=0.02,=6.28.Usingthefollowingcode,plotonthescreenintheregion0n100.

 

n=0:

100;

T=0.02;

omega=6.28;

fork=1:

101

x(k)=sin((k-1)*omega*T);

end;

stem(n,x);

 

Problem1-3:

Modifytheabovecodetodisplaythesignal:

whereT=0.02,=6.28.Executethecodeandplotthesignalonthescreen.Copythecode,thendisplaythesignalintothefollowingboxes.

 

n=0:

100;

T=0.02;

omega=6.28;

fork=1:

101

x(k)=2*sin((k-1)*omega*T+pi/2);

end;

stem(n,x);

 

Timeshift,impulseandstepresponses

Exercise1-4

Fortheunitimpulse,

andtheunitstep

writetwoMatlabfunctionsands

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 理学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1