东南大学Matlab作业2Word文件下载.docx
《东南大学Matlab作业2Word文件下载.docx》由会员分享,可在线阅读,更多相关《东南大学Matlab作业2Word文件下载.docx(46页珍藏版)》请在冰豆网上搜索。
ft)'
axis([00.2-260260]);
gridon;
2.Usingplottodisplaythefollowingvoltagewithappropriatelinetype,titleandlabels.Alsopresentthegraphwithsuitablerangesofaxis.
Inaddition,onthesamegraph,drawtheenvelopeoftheoscillationandaddlegends.
home_work_2_A_2.m
%lbsin-class-exercise1_22013/8/21
%functionUsingplottodisplaythefollowingvoltagewithappropriatelinetype,titleandlabels.Alsopresentthegraphwithsuitablerangesofaxis.
%v(t)=220exp(-5t)cos(2?
%Inaddition,onthesamegraph,drawtheenvelopeoftheoscillationandaddlegends.
clearall;
v=220*exp(-5*t).*sin(2*pi*50*t);
2);
v(t)=220exp(-5t)cos(2?
holdon;
v1=220*exp(-5*t);
plot(t,v1,'
b'
plot(t,-v1,'
holdoff;
legend('
theoscillation'
theenvelopeoftheoscillation'
);
axis([01-220220]);
3.Usesubplot,drawa2by2arrayofplotsforthefollowingfunctions:
Applyappropriatelinetype,title,labelsandaxisrangesforthegraphs.
home_work_2_A_3.m
%lbsin-class-exercise1_32013/8/21
%functionUsesubplot,drawa2by2arrayofplotsforthefollowingfunctions:
%v1=cos(10*pi*t);
v2=exp(-5*t).*v1;
v3=exp(-10*t).*v1;
v4=exp(-20*t).*cos(10*pi*t)
%Applyappropriatelinetype,title,labelsandaxisrangesforthegraphs.
v1=cos(10*pi*t);
v2=exp(-5*t).*v1;
v3=exp(-10*t).*v1;
v4=exp(-20*t).*cos(10*pi*t);
subplot(2,2,1)
k'
v(t)=cos(10?
t)'
axis([01-11])
subplot(2,2,2)
plot(t,v2,'
r'
v(t)=exp(-5t)cos(10?
subplot(2,2,3)
plot(t,v3,'
g'
v(t)=exp(-10t)cos(10?
subplot(2,2,4)
plot(t,v4,'
v(t)=exp(-20t)cos(10?
4.Useplot3toplot2spiralcurveslikebelowwithappropriatelinewidthandcolour.
(1)home_work_2_A_4_1.m
0.01:
10;
x=sin(2*pi*t).*exp(0.35*t-1);
y=cos(2*pi*t).*exp(0.35*t-1);
z=0.25*t;
plot3(x,y,z,'
axis([-1515-151503]);
(2)home_work_2_A_4_2.m
x=1.5*t.*sin(2*pi*t);
y=1.5*t.*cos(2*pi*t);
z=0.2*t;
3);
axis([-1515-151502]);
5.Displaythesurfaceusingmeshandcontourwithasuitableresolution:
home_work_2_A_5.m
[x,y]=meshgrid(0:
1:
100,0:
100);
z=exp(-0.005.*((x-50).^2+(y-50).^2));
figure
(1);
mesh(x,y,z),xlabel('
x'
),ylabel('
y'
),gridon;
figure
(2);
contour(x,y,z),xlabel('
6.Load2ofyourphotosintoMatlabWorkSpaceusingimread.a)Changebrightnesslocallyorglobally.b)Overlapthemtoproduceanewphoto.c)writeanewphotointoafileusingimwrite.(Note:
lowerversionofMatlabsuchas6.5isnotallowedtodosomedirectimageoperations.)
a)home_work_2_A_6_a.m
A=imread('
lbs.jpg'
subplot(2,2,1);
imshow(A),title('
初始图像'
size(A);
subplot(2,2,2);
B=histeq(A(:
:
1));
%Enhancecontrastusinghistogramequalization.
imshow(B),title('
对比度增大处理'
subplot(2,2,3);
C=imadjust(A,[0.3,0.7],[]);
imshow(C),title('
亮度调节处理'
subplot(2,2,4);
D=imfilter(A,2);
imshow(D),title('
真彩色增强处理'
b)home_work_2_A_6_b.m
B=imread('
man.jpg'
[M,N,L]=size(A);
C(1:
M,1:
N,1:
L)=B(1:
L);
imshow(A);
figure1'
imshow(C);
figure2'
figure(3);
imshow(A+C);
figure3'
c)home_work_2_A_6_c.m
B=imadjust(A,[0.2,0.6],[]);
imwrite(B,'
lbs1.jpg'
imshow('
7.Forlinearsimultaneousequations
theequationcoefficients:
A=[1-143
-545-6
07-89
-13-26];
(M=N)
a)FindthedeterminantofA,
b)FindtheinverseofAandcheckformatrixsingularity,
c)IfB=[5;
1;
-2;
3],findtheunknownxintheequation.
home_work_2_A_7.m
A=[1-143;
-545-6;
07-89;
disp('
a)determinantofA'
det(A)
b)theinverseofAandcheckformatrixsingularity'
inv(A)
cond(A)
B=[5;
3]
c)thesolutionoftheequation'
x=inv(A)*B
result:
>
home_work_2_A_7
a)determinantofA
ans=
-765.0000
b)theinverseofAandcheckformatrixsingularity
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
16.4186
B=
5
1
-2
3
c)thesolutionoftheequation
x=
-1.0000
-0.5882
0.7059
0.8627
8.Forlinearsimultaneousequations,
M>
N,theequationcoefficients:
-13-26
1-253
147-3];
a)FindthedeterminantofA’*A,
b)FindtheinverseofA’*Aandcheckformatrixsingularity,
3;
4;
0],findthesolutionoftheequation.
home_work_2_A_8.m
-13-26;
1-253;
047-3];
a)determinantofA¡
¯
*A'
det(A'
*A)
b)theinverseofA¡
*Aandcheckformatrixsingularity'
inv(A'
cond(A'
0];
x=inv(A'
*A)*A'
*B
home_work_2_A_8
a)determinantofA’*A
2.1051e+07
b)theinverseofA’*Aandcheckformatrixsingularity
0.08840.0321-0.0013-0.0219
0.03210.02310.0002-0.0099
-0.00130.00020.00850.0053
-0.0219-0.00990.00530.0144
32.5278
-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
.
home_work_2_A_9.m
x=1:
15;
y=[3.54.33.75.46.67.38.78.89.49.010.012.011.39.913.3];
plot(x,y,'
ro'
p=polyfit(x,y,1);
z=polyval(p,x);
plot(x,z,'
bx'
一阶拟合误差'
s1=sqrt(sum((z-y).^2))
p=polyfit(x,y,2);
kx'
Linewidth'
1.5);
二阶拟合误差'
s2=sqrt(sum((z-y).^2))
p=polyfit(x,y,3);
r--'
linewidth'
point'
polyfit1'
polyfit2'
polyfit3'
三阶拟合误差'
s3=sqrt(sum((z-y).^2))
result:
home_work_2_A_9
一阶拟合误差
s1=
3.2807
二阶拟合误差
s2=
3.0399
三阶拟合误差
s3=
3.0398
10.Createasetof20pointsfromacurvebyMatlabcode:
20;
y=2*exp(-0.3*(x-5).^2)+0.7*exp(-0.2*(x-12).^2);
Theninterpolatethecurveto60pointsusing‘linear’and‘spline’options,respectively.Seethequalityofdifferenttypesofinterpolation.
home_work_2_A_10.m
clearall,closeall;
xi=1:
1/3:
yi=interp1(x,y,xi,'
linear'
plot(xi,yi,'
b*'
spline'
m--'
PartB
1.Usingtheplotandsubplotfunctionscreate4plotsona2by2arrayofsubplots,forthefunctionexp(-t)sin(5t)showingineachplotthefunctioninthecorrespondingintervalsofti.e.(-2,-1),(-1,0),(0,1)and(1,2).
home_work_2_B_1.m
t=-2:
-1;
v=exp(-t).*sin(5*t);
subplot(2,2,1);
t=-1:
0;
t=1:
2;
2.Athreephaseinductionmotorcharacteristicisgivenintermsofmechanicalshaftoutputtorque
(NMNewton-meter)asafunctionofrotationalspeedω(rad/sradianpersecond).Thisisapproximatedby3piece-wiselinearequationsasfollows:
Thismotorisdirectlycoupledtoaload
whichcanberepresentedas
Write2separateMatlabfunctionm-filesinwhich:
a)themotorcharacteristic,b)theloadcharacteristicaredefinedonlyasfunctionsofω.Namethemmotor.mandsysload.m,respectively.
a)motor.m
function[Tm]=motor(w)
fori=1:
length(w);
ifw(i)>
=0&
w(i)<
=90*pi
Tm(i)=w(i)/(90*pi)+4.0;
elseifw(i)>
=90*pi&
=110*pi
Tm(i)=95*w(i)/(20*pi)-422.5;
elseif(w(i)>
=110*pi&
=120*pi)
Tm(i)=-10*w(i)/pi+1200;
end
end
motor(0)
4
w=0:
12*pi;
motor(w)
Columns1through10
4.00004.00354.00714.01064.01414.01774.02124.02484.02834.0318
Columns11through20
4.03544.03894.04244.04604.04954.05314.05664.06014.06374.0672
Columns21through30
4.07074.07434.07784.08134.08494.08844.0920