Professional Documents
Culture Documents
Do Thi Trong Matlab
Do Thi Trong Matlab
V th trong
Matlab
ntnhut@hcmus.edu.vn
TH 2D
Lnh plot
>> plot(x,f(x))
Vi:
f(x) - hm s cn v
x vect min gi tr ca hm f
ntnhut@hcmus.edu.vn
2/9/2010
V d hm plot
V th ca hm y = sin(x)
>> x = 0:pi/100:2*pi;
>> y = sin(x);
>> plot(x, y)
ntnhut@hcmus.edu.vn
ntnhut@hcmus.edu.vn
2/9/2010
Tham s ng nt ca th
>> plot(x,y,LinestyleMarkerColor)
Linestyle (nt v)
-
--
:
-.
ntnhut@hcmus.edu.vn
Marker (nh du nt v)
+
h/hexagram
>
s/square
<
d/diamond
p/pentagram
ntnhut@hcmus.edu.vn
2/9/2010
ntnhut@hcmus.edu.vn
V d v th vi cc tham s
>> x = 0:pi/20:2*pi;
>> plot(x, sin(x),-.*r);
ntnhut@hcmus.edu.vn
2/9/2010
Lnh hold on
Khi mun v thm th trn th hin c, ta s dng
lnh hold on. tt ch ny, s dng hold off.
V d
>>
>>
>>
>>
>>
x = 0:pi/10:2*pi;
plot(x, sin(x),'->r')
hold on
t =0:1:7;
plot(t, 2*t,'-*b');
ntnhut@hcmus.edu.vn
V d v nhiu th vi cc tham s
>>
>>
>>
>>
>>
>>
x = 0:pi/20:2*pi;
plot(x, sin(x),-.*r);
hold on
plot(x, sin(x pi/2),--om);
plot(x, sin(x pi), :bs);
hold off
ntnhut@hcmus.edu.vn
10
2/9/2010
ntnhut@hcmus.edu.vn
11
Cc tham s khc
ntnhut@hcmus.edu.vn
12
2/9/2010
V d v th vi cc tham s khc
>> x = -pi:pi/10:pi;
>> y = tan(sin(x)) - sin(tan(x));
>> plot(x,y,--rs','LineWidth',
2,'MarkerEdgecolor',
'k','MarkerFacecolor',
'g', 'MarkerSize',10)
ntnhut@hcmus.edu.vn
13
ntnhut@hcmus.edu.vn
14
2/9/2010
Xc nh kiu trc ta
Lnh axis
axis([xmin xmax ymin ymax])
axis on/off/auto
axis normal/square/equal/tight
axis ij/xy
grid on/off
ntnhut@hcmus.edu.vn
15
V d v kiu trc to
ntnhut@hcmus.edu.vn
16
2/9/2010
Xc nh gii hn ta
xlim([xmin xmax])
ylim(ymin ymax])
ntnhut@hcmus.edu.vn
17
ntnhut@hcmus.edu.vn
18
2/9/2010
XTick v YTick
V d
x = -pi:.1:pi;
y = sin(x);
plot(x,y)
set(gca,'XTick',-pi:pi/2:pi)
set(gca,'XTickLabel',
{'-pi','-pi/2','0','pi/2','pi'})
ntnhut@hcmus.edu.vn
19
ntnhut@hcmus.edu.vn
20
10