You are on page 1of 7

CAU HOI ON TAP MON HOC MO HNH HOA BANG SO

Hng dan: Xem theo tai lieu MATLAB6 Programming. Ve y ngha va cong dung mot so cac lenh co the xem trc tiep bang help ngay trong chng trnh MATLAB. Chu y: Ch can biet y ngha s dung, khong can nh cu phap (syntax). Nhm thc hin: t,Hng,Nguyn,Phc,V. 1) So thc s dung trong MATLAB c lu tr theo nh dang (format) nao?

S thc trong MATLAB c lu tr di dng Double, 16 ch s c ngha v c khong (range) t n .


2) Dau ; cuoi moi hang lenh trong MATLAB co y ngha g ? Tr li:

Tr li:

Du ; cui mi hng lnh khng cho hin th kt qu ca hng lnh (ln command window). Du ; v du , u dng ngn cch cc lnh. Du , cho hin th kt qu ln mn hnh.
3) Co may cach s dung tr giup trc tuyen (on-line help) cua MATLAB6? Tr li:

4) Mang (array) hoac ma tran (matrix) trong MATLAB c tao nh the nao bang dong lenh?

C hai cch s dng tr gip trc tuyn (on-line help) : dng lnh help t dng lnh hoc dng help window trnh by di dng vn bn siu lin kt (HTML).

Tr li: Mng (array) hoc ma trn trong matlab c to nh th no bng dng lnh?
Nhp cc gi tr cch nhau bi khong trng, cc hng cch nhau bi du chm phy ; , vo gia cp ngoc vung [ ] Nhp cc gi tr cch nhau bi khong trng, cc hng cch nhau bi du xung hang (shift enter) , vo gia cp ngoc vung [ ]

5) Cho ma tran A = [1 2 3; 4 5 6]. B = A co ket qua nh the nao?

Tr li: A = [1 2 3; 4 5 6] B = A = [1 4; 2 5; 3 6] (chuyn v ca A)
6) Vi A va B nh tren. C=[A B] co ket qua nh the nao?

C=[A B] khng biu din c. Cng s dng l c Cu 6.1 Php tnh A/B ngha l A*B-1.
7) Cac lenh ieu khien chng trnh (Program control) trong MATLAB bao gom nhng lenh g?

Cc lnh iu khin chng trnh (program control) bao gm : if-else-elseif, switch, break, continue, for, while, try-catch, return. Theo gio trnh lit k th gm c if, switch, for, while, break. Trc nghim: Cc lnh iu khin chng trnh (program control) trong MATLAB bao gm nhng lnh g ?

a. If, switch case, for, while, break b. If, switch case, for, while, repeat until c. If, switch case, for, while, exit Resp : a.
8) Script m-file la g? Function m-file la g? S khac nhau gia chung ? Tr li: -Script m-file l mt file vn bn cha 1 lot chui cc cu lnh.N khng c tham s u vo cng nh u ra.Khi gi tn n th n s thc hin mt chui cc cu lnh n cha -Function m-file l mt file vn bn c nh ngha bi t kha function. -im khc bit gia Script m-file v Function m-file l: +Hm(function) m-file khng c nhp t ca s lnh nh Script m-file m thng qua 1 qu trnh son tho bn ngoi. +Hm m-file c gi tr tham s u vo v tham s u ra,cc bin trung gian bn trong n th khng xut hin v khng tng tc vi mi trng ca matlab Tr li cu hi trc nghim trong thi: Script m-file v Function m-file l g? a) Function m-file l on m chung vit vi t kha cng khai function cha cc script m-file c th s dng nhiu ln b) Function m-file l on m c vit vi t kha khai bo function vi mc ch c th s dng nhiu ln trong on m ca script m-file c) Script m-file l on m chung cha cc function m-file 9) Phep tnh toan hnh thc trong MATLAB c s dung nh the nao? Tr li:

Cu 9: Php ton hnh thc trong matlab c s dng nh th no:


a) Dng t kho sym hoc syms khi u on m b) Sau khai khai bo bin bng t kho sym hoc syms c) S dng tng t kiu maple vi bin theo kiu string

10) Cho delta = MATLAB.

1 2E 2E 2E 2E ( 2 + 2 + 2 ) . Hay viet bieu thc cua delta bang dong lenh . c t 2 x y z

Tr li:

>> syms delta c E x y z t % phi c biu thc ca E theo t, x, y, z th cc lnh bn di mi c ngha, % % nu khng MATLAB s tr kt qu v 0 cho o hm ca E % delta=diff(E, 2, t)/c diff(E, 2, x) diff(E, 2, y) diff(E, 2, z)
11) Lenh e giai phng trnh vi phan trong MATLAB bang phng phap tnh hnh thc.

Cu 11 Lnh dsolve dng gii phng trnh vi phn bng phng php tnh hnh thc (nghim gii tch).

Cu 11.1 C php dsolve('eq1','eq2',...,'cond1','cond2',...,'v') VD : cu lnh gii pt vi phn no sau y l ng : A/ h=dsolve('Dx=y', 'Dy=x', 'x(0)=0', 'y(0)=1') B/ h=dsolve('Dx=y , Dy=x', 'x(0)=0 , y(0)=1') C/ C hai u ng
12) Tm hieu hai ham giai phng trnh vi phan tuyen tnh trong MATLAB c xay dngbang phng phap Runge-Kutta: ode23 va ode45. Phan biet chung.

Tm hiu hai hm gii phng trnh vi phn tuyn tnh trong MATLAB c xy dng bng phng php Runge-Kutta: ode23 v ode45.Phn bit chng. Resp : Cc hm ode dng gii phng trnh vi phn bng phng php s.Trong ode23 v ode45 l 2 hm s dng phng php Runge-Kutta vi : ode23 s dng 2 n 3 s k i (bc 2 hoc 3) cn ode45 s dng 4 n 5 s k i (bc 4 hoc 5),Runge-Kutta bc 4 thng c s dng nht trong tnh ton thc t.Thng dng ode45 gii pt vi phn tuyn tnh vi chnh xc cao, ode23 dng gii bi ton c dung sai li th vi chnh xc thp hn ode45. Hm ode23 khc vi hm ode45 c bn v : a. Bc pt vi phn b.ode23 gii pt n, ode45 gii h pt c. chnh xc ca li gii Resp : c.
13) Co may cach e giai phng trnh ao ham rieng bang MATLAB ? Tr li: -C 2 cch l: Dng cc hm pdeval,pdepe hoc dng phng php FEM thng qua PDE toolbox -Cu hi trc nghim: C my cch gii phng trnh o hm ring bng Matlab? a)Bin i thnh cc phng trnh vi phn thun ty v gii bng cc hm ode.. b)Lp trnh thng qua phng php ma trn c)2 cch :dng cc hm pdepe,pdeval hoc dng phng php FEM thng qua PDE toolbox 14) Co may cach e viet mot chng trnh trong MATLAB6 di dang giao dien o hoa ngi dung (GUI) ? a) Vit bng lp trnh thong qua cc lnh uicontrol, uimenu b) Vit trc tip cc on m chc nng thong qua ca s thit k GUI c) C 2 kh nng trn u c 15) Tm hieu cac khai niem uicontrol, uimenu? 16) Tm hieu y ngha mot so ham he thong quan trong khi lap trnh GUI: gcf, gca, gcbo, gco, gcbf. 17) Tm hieu y ngha mot so ham xuat nhap tap tin: f, feof, fopen, fprintf, fscanf, fwrite, fread

Resp : - feof : kim tra xem c ht file cha,nu ht tr v 1,nu cha tr v 0 - fopen : m file cn c - fprintf : in kt qu ra screen

fscanf : c v chuyn d liu ra file text fwrite : vit d liu ln file fread : c file

18) Tm hieu cac lenh o hoa 2D: plot, figure, polar, semilogx, axes, subplot i)Lnh Plot:v th tuyn tnh trong khng gian 2 chiu ca mt mng d liu,ni cc im bng ng thng nn n khng mn nh maple

ii)Lnh FIGURE a) Cng dng: To mi hnh nh ( th). iii)Lnh Polar: a) Cng dng: V th trong h trc ta cc. b) Gii thch: V gi tr x theo gi tr y. Cu hi trc nghim: a) V th trong ta cc b) Chuyn gi tr ta descarte v ta cc c) C a v b u khng ng Chn a) iv). Lnh SEMILOGX, SEMILOGY a) Cng dng: v th lograrith
-semilogx: thang chia ttheo trc x l logarithm cn theo trc y tuyn tnh -semilogy: thang chia theo trc y l logarithm cn theo trc x l tuyn tnh

v) Lnh AXES a) Cng dng: t cc trc ta (h trc ta ) theo v tr nh trc vi) Lnh SUBPLOT a) Cng dng: Cu hi trc nghim: a)V th con trong mt th ln b)V mt phn th c)V nhiu th trong mt figure Chn cu C)
19) Tm hieu cac lenh o hoa 3D: plot3, fill3, contour3, mesh, meshc, meshz

-Plot3: V ng thng 3D Syntax: plot3(X1,Y1,Z1,...)

V d:
t = 0:pi/50:10*pi; plot3(sin(t),cos(t),t) -Fill3: To nn bng phng ca a gic ( t mu 1 mt phng no ca 1 a gic) Syntax: fill3(X,Y,Z,C)

-Contour3: To nn ng ng mc 3D (ging nh cc ng bnh ni cc diem co cung do cao trn bn ) -Mesh: To mt li c mu th hin mt Z -Meshc: To mt li cho mt Z ng thi v cc ng ng mc bn di -Meshz: draws a curtain plot (i.e., a reference plane) around the mesh. Cu hi trc nghim: Lnh Mesh dng a) V trc cho th 3 chiu b) V th 3 chiu ca phn t c 3 to C) V b mt ca 1 hnh khi no . 20) Cong dung mot so lenh ve ma tran sau: ones, eye, rand, randn, size, length, diag, tril, triu, rot90, hadamard, pascal, solve, inv, chol, lu, eig, svd, sparse, speye, sprand, eigs, svds, interpn, spline, poly, polyfit.

Lnh ma trn ones/zeros to ma trn vi cc phn t ton 1/0 eye to ma trn vi cc phn t ton 0 v ng cho ton 1 rand to ma trn vi cc phn t ngu nhin theo phn phi u (uniformly distributed pseudorandom numbers s ngu nhin ng nht) randn ~ theo phn phi chun (normally distributed numbers) size tr v kch thc ma trn length tr v s phn t ca ma trn diag tr v ng cho ca ma trn tril tr v ma trn tam gic di (lower triangular part) triu tr v ma trn tam gic trn (upper triangular part) rot90 quay ma trn 90. hadamard to ma trn Hadamard* pascal to ma trn Pascal* solve gii nghim (symbolic) ca phng trnh i s inv tr v ma trn nghch o chol phn r Cholesky R = chol(A) R tho mn R'*R=A L = chol(A,'lower') R tho mn L*L'=A lu phn r LU [L, U] = lu(A) L, U tho mn L/U l mt tam gic di/trn v L*U = A eig tr ring (v vector ring) ca ma trn d = eig(A) d l tr ring ca A [V, D] = eig(A) D l tr ring, V l vector ring ca A : A*V=V*D svd phn r SVD [U, S, V] = svd(X) S : ma trn cho khng m, gim dn theo ng cho. U, V : ma trn unita. X=U*S*V' sparse to ma trn sparse* ma trn sparse l ma trn, theo mt thut ton lu tr no , loi b ton b cc phn t bng 0 tit kim b nh

speye to ma trn n v dng sparse* I = speye(3) I= (1,1) 1 (2,2) 1 (3,3) 1 sprand ging rand nhng lu tr di dng ma trn sparse eigs tr ring (v vector ring c di) ln nht ca ma trn svds find singular values and vectors interpn ni suy N-chiu (N-Dimention data interpolation) spline ni suy spline bc 3 (cubic spline data interpolation) poly hi quy polyfit ni suy a thc (?) (polynomial curve fitting)
21) SIMULINK trong Mat lab la g? Mo ta cac phan t chnh trong giao dien cua Simulink?

Simulink la mot phan mem m rong cua MATLAB (1 Toolbox cua Matlab) dung e mo hnh hoa, mo phong va phan tch mot he thong ong. Thong thng dung e thiet ke he thong ieu khien, thiet ke DSP, he thong thong tin va cac ng dung mo phong khac.
22) Mo ta cac lp khoi chc nang chnh (Sources, Sinks, Discrete, Linear, Nonlinear, Connections)

M t cc khi lp chc nng chnh (Sources, Sinks, Discreate, Linear, Nonlinear, Connections) Resp : - Sources : khi cp tn hiu vo (vung, tam gic, sin) - Sinks : khi cp cc dng c ly tn hiu ra (scope) - Discreate : khi cho tn hiu ri rc - Linear /Continuous : khi cho nhom tuyen tnh trong mien thi gian va Laplace/khi cho tn hiu trong min lin tc - Nonlinear:khi chc nng cho nhm phi tuyn - Connections : khi kt hp nh Sum, Add, Divide, Gain
23) Mot so s o SIMULINK chnh trong giai cac phng trnh vi phan. 24) Phng phap Monte Carlo la g? a) L phng php m phng s dng ngun s ngu nhin b) L phng php m phng da vo phn b u ngu nhin c) L phng php m phng da vo phn b bt k ngu nhin 25) Nguon so gia ngau nhien ong d tuyen tnh. Hieu ng Marsaglia.

Tr li: Ngun s gi ngu nhin ng d tuyn tnh : Hiu ng Marsaglia : bt ngun t h thng to s ngu nhin RANDU generator ca IBM : Khi to ngun s ngu nhin 1-chiu v 2-chiu th kt qu trng c v ngu nhin, nhng khi to ngun s 3-chiu th cc im ngu nhin tp trung v trung tm ca hnh lp phng n v :

Ngi ta i s 65 539 thnh s 69 069 v em li s thay i ng k cho h thng RANDU generator.


26) Cac phng phap lay so ngau nhien theo mot phan bo cho trc: phng phap loai tr, phng phap nghch ao. 27) V du mo phong phan ra phong xa 28) V du tnh tch phan bang pp Monte Carlo.