Professional Documents
Culture Documents
|0,4
|
>> theta=|0:p/90:4*p|;
>> r=2*theta;
>>poar(theta,r),tte('Duongxoan oc Archmede
r=2theta');
4.4 No th trong khong gan R
3
1. Ve ng trong khong gan 3 cheu:
Dung ham pot3(x,y,z) e ve ng cong trong
khong gan 3 cheu , x,y,z a cac vect co
cung so phan t . V du e ve ng cong
tham so x=e
-0.05t
snt , x=e
-0.05t
cost z=t trong o
tham so t thay o t 0 en 10
, cac enh nh
sau:
>> t=|0:p/50:10*p|;
>> x=exp(-0.05*t).*sn(t);
>> y=exp(-0.05*t).*cos(t);
>> z=t;
>> pot3(x,y,z),xabe('x'),yabe('y'),zabe('z'),grd;
2. Ve mat :
Ham 2 ben z=f(x,y) co the c beu den
bang 1 mat nao o trong he toa o xyz va
Matab cung cap ham mesh dung e ve mat
nay. Ne ve mat z=f(x,y) trc ten can pha
xay dng 1 he cac em trong mat
phang xy va tnh ga tr cua ham ta cac
em nut cua nay.
Ham meshgrd(x,y) , trong o vect x =|xmn:
x:xmax| co m phan t , y =|ymn: y:ymax| co n
phan t , xac nh pham v thay o cua cac
ben x,y. Ham meshgrd se am phat snh cac
toa o cua 1 ch nhat co m x n em
v 1 goc a (xmn,ymn) con goc ka a
(xmax,ymax). Ma tran X co kch thc m x n
gom n cot gong nhau a cac vect x va ma
tran Y cung co kch thc m x n gom m hang
gong nhau a vect y. Mo o cua se co
kch thc
x
va
y
.
Ke tep a tnh ma tran Z = f(X,Y); u y a
pha dung cac phep tnh ve mang ( xem C3 )
e vet beu thc tnh Z thay cho cac phep
tnh thong thng. Cuo cung enh ve
mesh(X,Y,Z) se ve mat z=f(x,y) trong he toa
o xyz. Cac enh xabe, yabe, zabe c
dung e gh cac chu thch theo cac truc tng
ng .
Lu y : Chung ta ng chon cac bc
x
va
y
qua nho v :
+ Cac ma tran X,Y se co kch thc rat
n , keo theo vec tnh toan Z kha au.
+ Cac o qua nho khen vec quan
sat cac mat tr nen kho khan.
V du : Ve mat z= xe
-x2-y2
>> x=|-2:.1:2|;
>> y=|-2:.1:2|;
>> |X,Y|=meshgrd(x,y);
>> Z=X.*exp(-X.2-Y.2);
>> mesh(X,Y,Z),xabe('x'),yabe('y'),zabe('z');
Sau kh mat c ve xong , ta co the s dung
cac cong cu tren toobar nh nut Rotate 3D
( nut co mu ten ngc cheu km ong ho )
e quan sat o th d cac goc nhn khac
nhau.
Cac enh ve tng t :
+ Neu s dung ham meshc(X,Y,Z) , chung ta
co ng ong mc ( contour nes ) pha d
mat.
+ Neu s dung ham meshz(X,Y,Z), chung ta co
them cac ng thang ng ( theo phng
truc z ) pha d mat.
+ Neu s dung ham surf(X,Y,Z) ta se c cac
mat gong nh thc hen enh mesh nhng mat
c to bong (shaded surface)
+ Neu s dung ham surfc(X,Y,Z) ta se c
cac mat gong nh thc hen enh meshc
nhng mat c to bong (shaded surface)
+ Ham contour(X,Y,Z) ve cac ng ong
mc tren mat phang xy .
4.5 Ve o th dung t e tren truc dang
ogart (ogarthmc pots)
Cac o th thong thng s dung t e tren
2 truc dang tuyen tnh (rectnear scaes) : cac
ga so bang nhau tren truc c the hen
bang cac oan bang nhau ( hoac cac moc
cach eu tao thanh cap so cong ).Tuy nhen
trong ky thuat cung hay s dung o th dung
t e dang ogart : tren cac truc , chung ta
thay ga tr cua a ng c the hen
bang cac con so dang uy tha 10 ( v du 10
-1
10
0
10
1
10
2
.) va cac em moc cach eu
nay tao thanh 1 cap so nhan v cong bo
a hang so tren mo truc.
Co 2 y do e dung o th dang nay :
+ Kh cac a ng thay o trong mot pham v
kha rong.
+ Can thay ro hn mot va ac em cua
o th ma enh pot khong thc hen c.
Matab co 3 ham dung e ve o th co t
e tren truc dang ogart.
1. Ham ogog(x,y) co ca 2 truc x,y eu dung
t e ogart.
2. Ham semogx(x,y) ch co truc x dung t
e ogart, truc y dung t e tuyen tnh.
3. Ham semogy(x,y) ch co truc y dung t
e ogart, truc x dung t e tuyen tnh.
V du:
>> x=|0.1:0.1:100|;
>> y=x.12+10;
>> subpot(2,2,1);pot(x,y),tte('Ve do th bang ham
pot');
>> subpot(2,2,2);ogog(x,y),tte('Ve do th bang
ham ogog');
>> subpot(2,2,3);semogx(x,y),tte('Ve do th bang
ham semogx');
>> subpot(2,2,4);semogy(x,y),tte('Ve do th bang
ham semogy');
4.6 Ve trng vect bang enh quver
Ga s chung ta co mot trng vect nh sau
trong khong gan R
2
:
P(x,y)= x ; O(x,y)=
y
, th ve hnh anh cua
trng nay trong pham v x
|1,5| va y
|1,5| .
Trc het ta vet mot scrpt e nh sau:
cear
hod oh
for x=1:5
for y=1:5
dx=sqrt(x); % thanh phan tren truc X
dy=sqrt(y); % thanh phan tren truc y
re=0.25; % he so t e 1/4
quver(x,y,dx,dy,re,'k-');% enh ve vecto (dx,dy) ta dem
(x,y)
axs('equa');
hod on % gu hnh
end
end
Lenh quver(x,y,dx,dy,re) se ve 1 vect co
em goc a em co toa o (x,y) va cac
thanh phan so tren ha truc X,Y a (dx,dy) v
he so t e a re.
Sau kh cho chay scrpt Fe nay , ta c hnh anh
nh sau:
Ngoa ra chung ta con dung enh feather(u,v)
e ve cac vect van toc co thanh phan
(u,v) phat xuat t nhng em co khoang
cach bang nhau doc theo mot truc ngang. Lenh
feather ten kh muon the hen hng va
o n cua vect doc theo mot ng .
>> theta=(-90:10:90)*p/180;r=2*ones(sze(theta));
>> |u,v|=po2cart(theta,r);
>> feather(u,v),axs equa
Ne tm heu them cac ham ve o th khac
cung cac ch tet , ca so Command Wndow
ta go :
Hep graph2d ( o th 2D ) hoac hep graph3d (o
th 3D)
>> hep graph2d
Two dmensona graphs.
Eementary X-Y graphs.
pot - Lnear pot.
ogog - Log-og scae pot.
semogx - Sem-og scae pot.
semogy - Sem-og scae pot.
poar - Poar coordnate pot.
potyy - Graphs wth y tck abes on the eft and
rght.
Axs contro.
axs - Contro axs scang and appearance.
zoom - Zoom n and out on a 2-D pot.
grd - Grd nes.
box - Axs box.
hod - Hod current graph.
axes - Create axes n arbtrary postons.
subpot - Create axes n ted postons.
Graph annotaton.
potedt - Toos for edtng and annotatng pots.
egend - Graph egend.
tte - Graph tte.
xabe - X-axs abe.
yabe - Y-axs abe.
texabe - Produces TeX format from a character
strng
text - Text annotaton.
gtext - Pace text wth mouse.
Hardcopy and prntng.
prnt - Prnt graph or Smunk system; or save
graph to M-e.
prntopt - Prnter defauts.
orent - Set paper orentaton.
See aso GRAPH3D, SPECGRAPH.
No command ne hep avaabe for graph2d.
Try "methods graph2d" to see a st of pubc
methods.
>> hep graph3d
Three dmensona graphs.
Eementary 3-D pots.
pot3 - Pot nes and ponts n 3-D space.
mesh - 3-D mesh surface.
surf - 3-D coored surface.
3 - Fed 3-D poygons.
Coor contro.
coormap - Coor ook-up tabe.
caxs - Pseudocoor axs scang.
shadng - Coor shadng mode.
hdden - Mesh hdden ne remova mode.
brghten - Brghten or darken coor map.
coordef - Set coor defauts.
graymon - Set graphcs defauts for gray-scae
montors.
Lghtng.
sur - 3-D shaded surface wth ghtng.
ghtng - Lghtng mode.
matera - Matera reectance mode.
specuar - Specuar reectance.
dhuse - Dhuse reectance.
surfnorm - Surface normas.
Coor maps.
hsv - Hue-saturaton-vaue coor map.
hot - Back-red-yeow-whte coor map.
gray - Lnear gray-scae coor map.
bone - Gray-scae wth tnge of bue coor map.
copper - Lnear copper-tone coor map.
pnk - Paste shades of pnk coor map.
whte - A whte coor map.
ag - Aternatng red, whte, bue, and back
coor map.
nes - Coor map wth the ne coors.
coorcube - Enhanced coor-cube coor map.
vga - Wndows coormap for 16 coors.
|et - Varant of HSV.
prsm - Prsm coor map.
coo - Shades of cyan and magenta coor map.
autumn - Shades of red and yeow coor map.
sprng - Shades of magenta and yeow coor
map.
wnter - Shades of bue and green coor map.
summer - Shades of green and yeow coor
map.
Transparency.
apha - Transparency (apha) mode.
aphamap - Transparency (apha) ook-up tabe.
am - Transparency (apha) scang
Axs contro.
axs - Contro axs scang and appearance.
zoom - Zoom n and out on a 2-D pot.
grd - Grd nes.
box - Axs box.
hod - Hod current graph.
axes - Create axes n arbtrary postons.
subpot - Create axes n ted postons.
daspect - Data aspect rato.
pbaspect - Pot box aspect rato.
xm - X mts.
ym - Y mts.
zm - Z mts.
Vewpont contro.
vew - 3-D graph vewpont speccaton.
vewmtx - Vew transformaton matrx.
rotate3d - Interactvey rotate vew of 3-D pot.
Camera contro.
campos - Camera poston.
camtarget - Camera target.
camva - Camera vew ange.
camup - Camera up vector.
campro| - Camera pro|ecton.
Hgh eve camera contro.
camorbt - Orbt camera.
campan - Pan camera.
camdoy - Doy camera.
camzoom - Zoom camera.
camro - Ro camera.
camookat - Move camera and target to vew
speced ob|ects.
cameratoobar - Interactvey manpuate camera.
Hgh eve ght contro.
camght - Creates or sets poston of a ght.
ghtange - Spherca poston of a ght.
Graph annotaton.
tte - Graph tte.
xabe - X-axs abe.
yabe - Y-axs abe.
zabe - Z-axs abe.
coorbar - Dspay coor bar (coor scae).
text - Text annotaton.
gtext - Mouse pacement of text.
potedt - Expermenta graph edtng and
annotaton toos.
Hardcopy and prntng.
prnt - Prnt graph or Smunk system; or save
graph to M-e.
prntopt - Prnter defauts.
orent - Set paper orentaton.
vrm - Save graphcs to VRML 2.0 e.
See aso GRAPH2D, SPECGRAPH.
No command ne hep avaabe for graph3d.
Try "methods graph3d" to see a st of pubc
methods.