matlab上機(jī)習(xí)題詳解-試題答案_第1頁(yè)
matlab上機(jī)習(xí)題詳解-試題答案_第2頁(yè)
matlab上機(jī)習(xí)題詳解-試題答案_第3頁(yè)
matlab上機(jī)習(xí)題詳解-試題答案_第4頁(yè)
matlab上機(jī)習(xí)題詳解-試題答案_第5頁(yè)
免費(fèi)預(yù)覽已結(jié)束,剩余40頁(yè)可下載查看

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、4、設(shè) y cos x 0.53sin x(1 x2)P第一次實(shí)驗(yàn)答案3 4t1 設(shè) y- e sin 4寸3t -23要求以0.01秒為間隔,求出y的151個(gè)點(diǎn), 并求出其導(dǎo)數(shù)的值和曲線。clcclearx=0:0.01:1.5;y=sqrt(3)/2*exp(-4*x).*sin(4*sqrt(3)*x+pi/3)y1=diff(y)subplot(2,1,1)plot(x,y)subplot(2,1,2)plot(x(1:150),y1)2繪制極坐標(biāo)系下曲線(a,b,n自定數(shù)據(jù))a cos b nclccleara=10;b=pi/2;n=5;theta=0:pi/100:2*pi;rh

2、o=a*cos(b+n*theta); polar(theta,rho)3.列出求下列空間曲面交線的程序z1x2 2y2z22x 3yclc clear x=-5:0.5:5; X,Y=meshgrid(x); z1=X.A2-2*Y.A2; z2=X.*2-Y.*3; xlabel( 'x') ylabel( 'y') zlabel( 'z') surf(X,Y,z1) hold on surf(X,Y,z2) k=find(abs(z1-z2)<0.5); x1=X(k) y1=Y(k) z3=x1.A2-2*y1.A2 hold on

3、 plot3(x1,y1,z3,'*')把x=02冗間分為101點(diǎn),畫出以x為橫坐標(biāo),y 為縱坐標(biāo)的曲線,要求有圖形標(biāo)注。clcclearx=-2*pi:0.1: 2*pi;y=cos(x).*(0.5+sin(x)*3./(1+x.A2);plot(x,y, 'b*-');title( '繪圖);xlabel('x 坐標(biāo));ylabel('y 坐標(biāo));legend('原函數(shù)')gtext( 'y=cos(x)(0.5+3*sin(x)/(1+xA2)'5、求下列聯(lián)立方程的解3x 4y7z 12w45x 7

4、y4z 2w3x 8z 5w 96x 5y 2z 10w8clccleara=3,4,-7,-12;5,-7,4,2;1,0,8,-5;-6,5,-2,10 ;b=4,-3,9,-8;c=b/a;x=c(1,1)y=c(1,2)z=c(1,3)w=c(1,4)6.假設(shè)一曲線數(shù)據(jù)點(diǎn)為x = 0:2:4*pi;y = sin(x).*exp(-x/5);試將x的間距調(diào)成0.1 ,采用不同插值方法進(jìn)行 插值,并通過(guò)子圖的形式將不同插值結(jié)果和原始數(shù)據(jù)點(diǎn)繪制在同一圖形窗口clcclearx=0:2:4*pi;y=sin(x).*exp(-x./5);x1=0:0.1:4*pi;y01=interp1(x

5、,y,x1,'spline'y02=interp1(x,y,x1,'cubic'y03=interp1(x,y,x1, y04=interp1(x,y,x1); subplot(3,2,1);plot(x,y,'o-');title( '?-o e y');subplot(3,2,2);plot(x1,y01,'gx-'title( 'spline');subplot(3,2,3);plot(x1,y02,'m+-'title( 'cubic' ); subplot(

6、3,2,4);plot(x1,y03,'r*-'title( 'nearest');subplot(3,2,5);plot(x1,y04,'kd-''nearest'););););title( 'line' );第二次試驗(yàn)答案1、編制 m 文件,等待鍵盤輸入,輸入密碼20120520,密碼正確,顯示輸入密碼正確,程序結(jié)束;否則提示,重新輸入。cleara=input(' 輸入密碼 :')while a=20120520disp(' 密碼錯(cuò)誤,請(qǐng)重新輸入 :')cleara=inpu

7、t(' 輸入密碼 :')endif a=20120520disp(' 密碼輸入正確 !')end2、編寫一個(gè)函數(shù)實(shí)現(xiàn)以下功能:a. 若沒有實(shí)參輸入變量,則用藍(lán)色實(shí)線畫出半徑為 1 的圓;b.若有兩個(gè)實(shí)參輸入變量N, R,則用藍(lán)色實(shí)線畫出外接半徑為 R 的正 N 多邊形;d. 若有兩個(gè)實(shí)參輸出變量,則分別輸出正多邊形的面積S 和周長(zhǎng) L 。g. 如果輸入變量多于三個(gè)或輸出變量多于兩個(gè)則給出錯(cuò)誤提示信息。( 提示 : 外接半徑為 R 的正 N 多邊形參數(shù)式 :t=0:2*pi/N:2*pi;x=R*sin(t);y=R*cos(t) 當(dāng) N100時(shí),可看作是半徑為R

8、的圓)function S,L=shiyan22(N,R,str)switch nargincase 0N=100;R=1;str='-b'case 1R=1;str='-b'case 2str='-b'case 3;otherwiseerror(' 輸入量太多。 ');end;t=0:2*pi/N:2*pi;x=R*sin(t);y=R*cos(t);if nargout=0plot(x,y,str);elseif nargout>2error(' 輸入量太多。 ');elseS=N*R*R*sin(2*p

9、i/N)/2;L=2*N*R*sin(pi/N);plot(x,y,str)endaxis equal squarebox on3、編寫一個(gè)學(xué)生成績(jī)管理的程序,完成下列功能:(1) 構(gòu)造一個(gè)學(xué)生結(jié)構(gòu),包括學(xué)生的姓名,課程名稱(限M 門) ,考試成績(jī)和平均值等域;(2) 從鍵盤上,連續(xù)輸入N 個(gè)學(xué)生的情況, 分別將這些學(xué)生的情況填入到相應(yīng)的域, 若域中沒有值即為空或0,并分別計(jì)算其平均值寫入到其平均值域。(3) 根據(jù)平均值排序(由高到低) ,并輸出學(xué)生的姓名和平均值。clcclearn=input('please input students number:');for x=1:

10、nnumber(x)=struct('name','','Curriculum1','','Curriculum2','','Curriculum3','','Average','');end精選4、使用句柄圖像對(duì)象繪制曲線:y=2e-0.5xcos(冗 x),同時(shí)對(duì)曲線進(jìn)行標(biāo)注和修飾。h_t=title(h_a1,' 函數(shù)=2*exp(-0.5)*x).*cos(pi*x)')h_1=line(x,y)set(gca,

11、'xtick',(-6)*pi (-4)*pi (-2)*pi 0(2)*pi (4)*pi (6)*pi)set(gca,'xticklabel','(-6)*pi',' (-4)*pi','(-2)*pi','0','(2)*pi','(4)*pi','(6)pi')set(gca,'xgrid','on','ygrid','on')set(h_1,'linewidth'

12、;,2)set(get(h_t,'parent'),'color','y')h_anm1=annotation(gcf,'rectangle',0.10.5 .80.4,'FaceAlpha',.7,'FaceColor','red')for i=1:nnumber(i).name=input('name:','s');number(i).Curriculum1=input('pleaseinput the scoresnCurriculum1

13、:');number(i).Curriculum2=input('Curriculum2:') ;number(i).Curriculum3=input('Curriculum3:') ;number(i).Average=(number(i).Curriculum1+number(i).Curriculum2+number(i).Curriculum3)/3;disp('the average is:')disp(num2str(number(i).Average)endNameCell=cell(1,n);Array=1,n;for

14、i=1:nNameCell(1,i)=number(i).name;Array(i)=number(i).Average;endfor j=1:(n-1)iptr = j;for i=(j+1):nif Array(i)>Array(iptr) % 比較相鄰前后大小 ?iptr=i;endendif j=iptr%若后面比前面大,互換Name=NameCell(1,i);NameCell(1,i)=NameCell(1,j);NameCell(1,j)=Name;average=Array(i);Array(i)=Array(j);Array(j)=average;j=1;iptr=j;

15、endenddisp(' 成績(jī)排序如下: ')for i=1:ndisp(strcat('名次 : ',num2str(i),'名字',NameCell(1,i),'平均成績(jī) :',num2str(Array(i)end x=-12:0.02:12y=2*exp(-0.5)*x).*cos(pi*x) h_f=figure('Position',200 300 300 300,'menubar','none')h_a1=axes('position',0.1,0.1,

16、.8,.8)第三次試驗(yàn)答案1、做一個(gè)帶按鈕的界面,當(dāng)按動(dòng)“播放”按鈕時(shí)調(diào)入聲音文件并播放, 顯示聲音波形, 并建立一個(gè)用于關(guān)閉界面的按鈕對(duì)象。 (提示,找一個(gè) .wav 文件,簡(jiǎn)單起見可以在windows目錄下找一個(gè)文件, 將其放在當(dāng)前工作目錄下或搜索路徑上。具體用法請(qǐng)參照:y,f,b=wavread(*.wav'); % 讀入聲音文件sound(y,f,b)% 由 聲 卡 播 放聲音plot(y)% 畫出波形2、創(chuàng)建一個(gè)用于繪圖參數(shù)選擇的菜單對(duì)象,其中包含三個(gè)選項(xiàng) LineStyle、Marker和Color,每個(gè)選項(xiàng)下面又包含若干的子項(xiàng)分別可以進(jìn)行選擇圖線的類型、 標(biāo)記點(diǎn)的類型和顏

17、色(每個(gè)子項(xiàng)不少于3 個(gè)),當(dāng)按下“繪圖”按鈕時(shí),根據(jù)選項(xiàng)繪制正弦曲線 (缺省時(shí)為藍(lán)色無(wú)標(biāo)記實(shí)線)。 (注意使用全球變量)function varargout = shiyan32(varargin)% SHIYAN32 MATLAB code for shiyan32.fig% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name' ,mfilename, .'gui_Singleton' ,gui_Singleton, .'gui_O

18、peningFcn' , shiyan32_OpeningFcn, .'gui_OutputFcn',shiyan32_OutputFcn, .'gui_LayoutFcn', ,.'gui_Callback' , );if nargin && ischar(varargin1)gui_State.gui_Callback =str2func(varargin1);endif nargoutvarargout1:nargout =gui_mainfcn(gui_State, varargin:); elsegui_main

19、fcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT% - Executes just before shiyan32 is made visible.function shiyan32_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, seeOutputFcn.% hObject handle to figure% eventdata reserved - to be defined in

20、afuture version of MATLAB% handles structure with handles and userdata (see GUIDATA)% varargin command line arguments toshiyan32 (see VARARGIN)% Choose default command line output forshiyan32handles.output = hObject;% Update handles structure guidata(hObject, handles);% UIWAIT makes shiyan32 wait fo

21、r user response (see UIRESUME)% uiwait(handles.figure1);global cc= 'b'globalll= '-'globalmm=' '% - Outputs from this function are returned to the command line.function varargout =shiyan32_OutputFcn(hObject, eventdata, handles)% varargout cell array for returning output args (

22、see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in afuture version of MATLAB% handles structure with handles and user data (see GUIDATA)% Get default command line output from handles structurevarargout1 = handles.output;function Untitled_1_Callback(hObject, eventdata, h

23、andles)% hObject handle to Untitled_1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global l% function Untitled_8_Callback(hObject, eventdata, handles)% hObject handle to Untitled_8 (see GCBO) % eventdata rese

24、rved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global m% function color_Callback(hObject, eventdata, handles)% hObject handle to color (see GCBO)% eventdata reserved - to be defined in afuture version of MATLAB% handles structure with ha

25、ndles and userdata (see GUIDATA)global c% function Untitled_14_Callback(hObject, eventdata, handles)% hObject handle to Untitled_14 (see GCBO)% eventdata reserved - to be defined in afuture version of MATLAB% handles structure with handles and userdata (see GUIDATA)global c c='r' %function U

26、ntitled_15_Callback(hObject, eventdata, handles)% hObject handle to Untitled_15% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and userdata (see GUIDATA)global cc='b'%(see GCBO)future version of MATLAB% handles structure with handles and use

27、r data (see GUIDATA)global mm='*'%function Untitled_16_Callback(hObject, eventdata, handles)% hObject handle to Untitled_16% eventdata reserved - to be defined in afuture version of MATLAB% handles structure with handles and userdata (see GUIDATA)global cc='g'%function Untitled_13_Ca

28、llback(hObject, eventdata, handles)% hObject handle to Untitled_13% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global mm='d'%(see GCBO)(see GCBO)function Untitled_17_Callback(hObject, eventdata, handles)% hObjec

29、t handle to Untitled_17% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and userdata (see GUIDATA)global cc='y'%function Untitled_4_Callback(hObject, eventdata, handles)% hObject handle to Untitled_4 (see GCBO) % eventdata reserved - to be de

30、fined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global ll='-'%(see GCBO)function Untitled_10_Callback(hObject, eventdata, handles)% hObject handle to Untitled_10% eventdata reserved - to be defined in a future version of MATLAB% handles structur

31、e with handles and userdata (see GUIDATA)global mm='o'%function Untitled_5_Callback(hObject, eventdata, handles)% hObject handle to Untitled_5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global ll=&#

32、39;-'%(see GCBO)function Untitled_11_Callback(hObject, eventdata, handles)% hObject handle to Untitled_11% eventdata reserved - to be defined in a(see GCBO)function Untitled_7_Callback(hObject, eventdata, handles)% hObject handle to Untitled_7 (see GCBO) % eventdata reserved - to be defined in a

33、 future version of MATLAB% handles structure with handles and user data (see GUIDATA)global ll='-.'% - Executes on button press infunction pushbutton1_Callback(hObject, eventdata, handles)pushbutton1.r.rjk 1i, j, 1,2,L ,1030分)% hObject handle to pushbuttonl (see GCBO) % eventdata reserved -

34、to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) global s global l global m global c x=0:0.1:2*pi;y=sin(x);s=strcat(l,m,c);plot(x,y,s)2 .設(shè) A (ai j )10 10 和 B (bi j )1010 是兩個(gè) 10 行 10 列 的矩陣(數(shù)組),試說(shuō)明命令A(yù)*B, A/B, AB, A.*(B.AA), A./B, A B 和 sin(A).*exp

35、(B)的涵義。A,B的矩陣乘法,矩陣 A乘以B的逆,矩陣B乘以A的 逆,B的每個(gè)元素的對(duì)應(yīng) A次哥乘以A對(duì)應(yīng)的每個(gè)元素 A的每個(gè)元素除以 B對(duì)應(yīng)的每個(gè)元素,B的每個(gè)元素除以 A對(duì)應(yīng)的每個(gè)元素,A的每個(gè)元素的正弦與B對(duì)應(yīng)的每個(gè)元素的指數(shù)求積,3 .設(shè)A為14 17數(shù)組,B為一個(gè)行數(shù)大于3的數(shù)組,請(qǐng) 給出(1)刪除A的第4、8、12三列的命令;(2)刪除B的倒數(shù)第3行的命令;(3)求符號(hào)極限lim tan(mx)的命令集;(4)求 x 0 nxy arctan x_3 ln(1 e 2x)的3階導(dǎo)數(shù)的命令集;(5) x 212計(jì)算定積分Jx| sinx)x2dx的命令,并給出計(jì)算結(jié)果A(:,4 8

36、 12)=口(2)B(end-2)=口(3)syms m n xlimit(tan(m*x)/(n*x)(4) syms x yy=atan(x+3)/(x-2)-log(1+exp(-2)*x)diff(y,3)(5)syms xint(abs(x)+sin(x)*xA2,-1,1)三.基本編程題(每小題 10分,共得分1. Write a program to compute the following expressions10(xikxi)(xjkxj)5Here, we suppose the variable x has existed in the workspace.for i

37、=1:10for j=1:10xbar(i)=xbar(i)+x(i,j);endxbar(i)=xbar(i)/10;endfor i=1:10for j=1:10t1=0;t2=0;t3=0;for k=1:3t1=t1+(x(i,k)-xbar(i)*(x(j,k)-xbar(j);t2=t2+(x(i,k)-xbar(i)A2;t3=t3+(x(j,k)-xbar(j)A2;endr2(i,j)=t1/sqrt(t2*t3);endendr22. (1) Using plot() function to plot the curves of 2xsin xy sin(2 x) cos3

38、xe and z xin the range of x 2 , 2, let their color are red andgreen respectively, and add the grid to the figure. (2) Using fplot() function and ezplot() function to plotabove-mentioned (上述的)curves respectively.(1)x=-2*pi:pi/100:2*pi;y=(sin(2*x)+cos(3*x).*exp(-2*x);z=sin(x)/x;plot(x,y, 'r',x

39、,z,'g')(2)fplot('(sin(2*x)+cos(3*x).*exp(-2*x),sin(x)/x',-2*pi2*pi)3. Plot the 3D mesh figure and 3D surface figure of the function2 x2/2 (y 1)2f (x, y) 9(1 x) ein the range of 4 x 4 and 4 y 4, respectively.x=-4:1/100:4;y=-4:1/100:4;z=9(1-x)A2*exp(-x 'A2/2-(y '+1)A2)mesh(x,y,

40、z);surf(x,y,z);得分共共22分)四.綜合編程題(每小題 11分,1. Write a function functionprogram to compute the following|2i |! ,x i (整數(shù))4sin(2 x)x1.8,其他endxbar=s/(i-1)m=0;for j=1:i-1m=m+(x(i)-xbar)A3;endske=m/(i-1)and call this function program to compute the value of y=f1(-4)+f1(3)-f1(14.37) in main program or command

41、window, there, |i |! shows the factorial (階乘)of |i|.提示:對(duì)x取整的函數(shù)有 fix(x), floor(x), round(x) 和 ceil(x).fuction y=f1(x)%f1.mif x-fix(x)= =0y=prod(1:abs(2*x);elsey=4*sin(2*x)+xA1.8 ;y=f1(-4)+f1(3)-f1(14.37) 2.Write a program to compute the sample meanxbar =and the sample skewness 偏度) ,1 n , ske 一 (xn i

42、1for the following three case: n and x x1, x2, xnMatlab. It is no any limit;(2) n and xx,x2, xnxi ,3x)exist in Workspace of are unknown variables.Please input x by keyboard one by one, and give a mark of end the data input. Examinees can use loop statement and length() function and input() function,

43、 but cannot use mean() function, std() function, and var() function directly (可以使 用循環(huán)語(yǔ)句和length()函數(shù)、input()函數(shù)等進(jìn)行編程,但不 能直接使用mean()、std()和var()等函數(shù)).s=0;for i=1:ns=s+x(i);endxbar=s/nm=0;for i=1:nm=m+(x(i)-xbar)A3;end ske=m/n (2)x(1)=input('請(qǐng)輸入 x '); i=1;s=0;while(x(i)='a')s=s+x(i);i=i+1;

44、x(i)=input('請(qǐng)輸入 x,輸a'結(jié)束');一、填空題1、MATLAB常用操作界面包括命令窗口、工作空間窗口、命令歷史窗口、當(dāng)前目錄窗口 、內(nèi)存數(shù)組編輯器、M文件編輯/調(diào)試器、幫助導(dǎo)航/瀏覽器、 圖形窗口等。2、MATLAB 中Inf或inf表示 無(wú)窮大、NaN 或nan表示不是一個(gè)數(shù) 、nargout表示函數(shù)輸出變量 數(shù)目 。3、工作空間瀏覽器主要用于內(nèi)存變量的查閱、保持和 編輯 O4、MATLAB實(shí)現(xiàn)將全下標(biāo)轉(zhuǎn)換為單下標(biāo)的指令為 sub2ind、據(jù)單下標(biāo)換算出全下標(biāo)的指令為 ind2sub。5、MATLAB 中clf用千 清除圖形窗口 、clc用于_清 除指

45、令窗口中顯示內(nèi)容 、clear用于 清除 MATLAB 工 作空間中保存的變量 。二、簡(jiǎn)答題(每題 5分,共20分)1、簡(jiǎn)述MATLAB歷史指令窗的主要作用。答:歷史指令窗記錄著用戶在MATLAB指令窗中所輸入過(guò)的所有指令。歷史記錄包括:每次開啟MA TLAB的時(shí)間,每次開啟MATLAB后在指令窗中運(yùn)行過(guò)的所有指令。應(yīng)用功能有單行或多行指令的復(fù)制和運(yùn)行、生成M文件等。2、簡(jiǎn)述MATLAB函數(shù)的基本結(jié)構(gòu)。答:典型M函數(shù)文件的結(jié)構(gòu):函數(shù)申明行、 H1行、在線 幫助文本區(qū)、編寫和修改記錄、函數(shù)體。3、簡(jiǎn)述繪制二維圖形的一般步驟。繪制二維圖形的一般步驟為:曲線數(shù)據(jù)準(zhǔn)備、選定圖形窗及子圖位置、調(diào)用二維曲

46、線繪圖指令、設(shè)置軸的范圍、坐 標(biāo)分格線、圖形注釋、圖形的精細(xì)操作。三、閱讀程序并回答問(wèn)題(每題 4分,共28分)1、寫出下列指令運(yùn)行結(jié)果。A=zeros(2,4);A(:)=1:8;s=2 3 5; A(s)Sa=10 20 30'A(s)=Sa ans =235Sa =102030A =120307104682、寫出下列指令運(yùn)行結(jié)果。A=reshape(1:16,2,8)reshape(A,4,4)s=1 3 6 8 9 11 14 16;A(s)=0A 2ans4681012141615913261014371115481216A =00570013152

47、4001012003、寫出下列指令運(yùn)行結(jié)果。A=1,2;3,4;B=-1,-2;2,1;S=3;A.*Bans =-1-464A*Bans =305-2S.*Aans =36912S*Bans =-3-6634、下面的函數(shù)主要完成什么功能?function f=factor(n)if n<=1f=1;elsef=factor(n-1)*n;end利用函數(shù)的遞歸調(diào)用求n!5、寫出下列指令運(yùn)行結(jié)果。ch= ABc123d4e56Fg9; subch=ch(1:5)revch=ch(end:-1:1)k=find(ch>= a &ch<= z );ch(k)=ch(k)-

48、( -a A );char(ch)subch =ABc12 revch = 9gF65e4d321cBA ans =ABC123D4E56FG9 ans =46 、 寫出下列指令運(yùn)行結(jié)果。A(1,1)='this is cell'A1,2=1 2 3;4 5 6;A2,1=1+2*i;A2,2=A1,21+(A1,21(1,1)+A1,21(2,2); celldisp(A)A1,1 = this is cellA2,1 =1.0000 + 2.0000iA1,21 =123456A2,2 =789101112 7、下面的程序完成功能是什么?t=0:pi/50:4*pi;y0=

49、exp(-t/3);y=exp(-t/3).*sin(3*t);plot(t,y,'-r',t,y0,':b',t,-y0,':b') xlabel( bfit t );ylabel( bfit y );grid on;繪制圖形如下: 四、編程題( 32 分)1、用命令來(lái)創(chuàng)建GUI 并繪制方程y=ax2 +bx+c 圖形,需要顯示繪圖結(jié)果的坐標(biāo)系窗口,還能輸入a、 b 、 c 的值和x 的取值范圍,同時(shí)用命令設(shè)置所以對(duì)象的屬性。2、在同一圖上分別用紅色實(shí)線和綠色虛線繪制y1=sin(x)和y2=cos(x)在區(qū)間0, 4*pi的曲線,并用星號(hào)*標(biāo)

50、出兩條曲線的交點(diǎn)以及建立圖例。( 5 分)x=0:0.01:4*pi;y1=sin(x);y2=cos(x);z=find(abs(y1-y2)<0.007);plot(x,y1,'r.-','Linewidth',2,'Markersize',1);axis(-1.5,15,-1.5,1.5);hold onplot (x,y2,'g.:','Linewidth',2,'Markersize',1);Gc(s)20(s 1)(s 2)(s 1.5)(s 23)n=size(z);plot(x

51、(z),y1(z),'k*','Markersize',15);3、某商場(chǎng)對(duì)顧客所購(gòu)買的商品實(shí)行打折銷售,標(biāo)準(zhǔn)如下(商品價(jià)格用price來(lái)表示):price<200沒有折扣200 & price<5003%折扣500 < price<10005%折扣1000 < price<25008%折扣2500 & price<500010%折扣5000 < prie14%折扣輸入所售商品的價(jià)格,求其實(shí)際銷售價(jià)格。(5分)price=input('please input your price:'

52、;);a=0;if price<200a=1;elseif price<500a=2;elseif price<1000a=3;elseif price<2500a=4;elseif price<5000a=5;else a=6;endswitch acase 0disp('0 inputs given');case 1b=price;case 2b=0.97*price;case 3b=0.95*price;case 4b=0.92*price;case 5b=0.90*price;case 6b=0.86*price;otherwisedisp

53、('unexpected input!');endfprintf('the actaul price is %f,b);4、二階微分方程 x"+0.2x'+0.4x=0.2u (t),其中u是 單位階躍函數(shù),試建立系統(tǒng)模型并仿真。的值。1.function s=zh(x,n)if nargin>2,error('wrong');endif nargout>1,error('wrong');endss=1;for t=1:n,ss=ss+(xAt)./(2*t-1);s=ss;end>> zh(35

54、/60,35) ans =1.76772.已知系統(tǒng)的框圖如下圖所示,請(qǐng)推導(dǎo)出從輸入信號(hào)到輸出信號(hào)y的總系統(tǒng)模型。2.syms G1 G2 G3 G4 G5 G6 G7 H1 H2 H3 H4c1=feedback(G4,H4);c2=feedback(G3*G2,H2);c3=feedback(G5*c1,H3);G=feedback(G6+G7)*c3*c2*G1,H1)3. 已知單位負(fù)反饋控制系統(tǒng)的被控對(duì)象及控制器的傳遞 函數(shù)分別為G(s) - s/2.5), s(1 s/0.5)(1 s/20)試判斷系統(tǒng)的穩(wěn)定性,并用時(shí)域響應(yīng)檢驗(yàn)得出的結(jié)論。>> s=tf('s

55、9;)Transfer function: s >> Gs=16*(1+s/2.5)/s*(1+s/0.5)*(1+s/20)Transfer function:6.4 s + 16 0.1 sA3 + 2.05 sA2 + s>> Gc=20*(s+1)*(s+2)/(s+1.5)*(s+23)Transfer function:20 sA2 + 60 s + 40S 1 xx2x3xn352n1并利用該M-函數(shù)計(jì)算n =學(xué)號(hào)末2位數(shù)+5, x =n/60 時(shí) S1.請(qǐng)編寫一個(gè) M-函數(shù),用來(lái)實(shí)現(xiàn)級(jí)數(shù)和sA2 + 24.5 s + 34.5>> GG=feedback(Gs*Gc,1)Transfer function:128 sA3 + 704 sA2 + 1216 s + 6400.1 sA5 + 4.5 sA4 + 182.7 sA3 + 799.2 sA2 + 1251 s + 640>> eig(GG)ans =-20.1421 +

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論