Bài giảng Mô hình và mô phỏng - Chương 2b: Câu lệnh MATLAB - Nguyễn Chí Nghĩa
Notion de functions
sin(pi/4)
ans = 0.7071
cree fichee M-file : Velocity.m
function v = Velocity(v0, a, t)
v = v0 + a.*t;
Utilisez dans work espace
v = Velocity( 30, 9.81, 1 );
Ouvert M-file
Creer function
Sauvagader pour les utiliser
> Files > save as >
Polynom
x = [1 3 -15 -2 9]
x = [1 0 0 0 1]
Valeu du Polynom
z = polyval( [1 0 0 0 1], 2 )
Multiplication les polynoms
X = S + 2
et
Y = S2 + 4S + 8 => Z = S3 + 6S2 + 16S + 16
=x = [1 2]; y = [1 4 8]; z = conv( x, y )
x = [1 2]; y = [1 4 8]; z = conv( x, y )
Z=
1 6 16 16
Decomposer le polynom Z
[xx, R] = deconv( z, y )
XX =
1 2
R =
0
0
0
0
Racine de polinome
P=[1 0 -2 -5]
R = roots(p)
R=
2.0946
-1.0473 + 1.1359i
-1.0473 - 1.1359i
P=poly(R)
P=
1
0
-2
-5
Matrices
B = [1 2 3 4; 5 6 7 8; 9 10 11 12]
B = [ 1 2 3 4
5 6 7 8
9 10 11 12]
C = B'
D = B * C
E = [1 2; 3 4]
F = [2 3; 4 5]
G = E .* F
E^3
X = inv(E)
Plot
t = 0:0.25:7;
y1 = sin( t );
y2 = cos( t );
y3 = y1 + y2;
y4 = y1 - y2;
subplot( 2, 2, 1 );
plot( t, y1 )
subplot( 2, 2, 2 );
plot( t, y2 )
subplot( 2, 2, 3 );
plot( t, y3 )
subplot( 2, 2, 4 );
plot( t, y4 )
plot(t, x, t, y);
Plot
t = -pi:pi/10:pi;
y = sin( t );
plot( t, y, '--o', 'LineWidth', 2,...
'MarkerEdgeColor', 'r',...
'MarkerFaceColor', 'g',...
'MarkerSize', 10 )
t = -pi:.1:pi;
y = sin( t );
plot( t, y )
set( gca, 'XTick', -pi:pi/2:pi )
set( gca, 'XTickLabel', { '-pi', '-pi/2' , '0' , 'pi/2' , 'pi' } )
xlabel( '-\pi \leq \alpha \leq \pi' )
ylabel( 'sin(\alpha)' )
title( 'Plot of sin(\alpha)' )
text( -pi/4, sin(-pi/4), '\leftarrow sin(-\pi\div4)')
Plot
Plot polar coordinates
polar(theta,rho)
polar(theta,rho,LineSpec)
t = 0:.01:2*pi;
polar( t, sin( 2*t ) .* cos( 2*t ), '--r' )
Histogram plot
Bar chart
x = -2.9:0.1:2.9;
y = randn( 10000, 1 );
hist( y, x )
x = -2.9:0.2:2.9;
bar(x,exp(-x.*x))
Lineair 3-D plot
t = 0:pi/50:10*pi;
plot3( sin( t ), cos( t ), t )
grid on
axis square
Two-dimensional comet plot
t = 0:.001:4*pi;
x = sin(t);
y = cos(t);
comet(x,y);
Three-dimensional comet plot
t = -10*pi:pi/250:10*pi;
comet3( sin( t ), cos(t), t);
Exercises
Oscillations;
Circular motion
Projectile motion
Bạn đang xem tài liệu "Bài giảng Mô hình và mô phỏng - Chương 2b: Câu lệnh MATLAB - Nguyễn Chí Nghĩa", để tải tài liệu gốc về máy hãy click vào nút Download ở trên
File đính kèm:
bai_giang_mo_hinh_va_mo_phong_chuong_2b_cau_lenh_matlab_nguy.ppt

