TP 1
TP 1
>> a=2
a=
>> a=2;
>> a=3
a=
This MATLAB function saves all variables from the current workspace in a MATLAB
save(filename)
save(filename,variables)
save(filename,variables,fmt)
save(filename,variables,version)
save(filename,variables,'-append')
save filename
slvnv/rmidata.save, simulink/Simulink.Bus.save,
simulink/Simulink.sdi.save
>> save
>> a.mat
>> save
>> save(a)
>> save a
>> load('a.mat')
>> a
>> who
>> what
a matlab
>> who
Your variables are:
A=
1 2 3
4 5 6
7 8 9
>> size(A)
ans =
3 3
>> A'
ans =
1 4 7
2 5 8
3 6 9
>> A(3,2)
ans =
>> A(:,3)
ans =
>> A(1,:)
ans =
1 2 3
>> inv(A)
1.0e+16 *
>> det(A)
ans =
6.6613e-16
>> trace(A)
ans =
15
>> eye(4)
ans =
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
>> diag(2)
ans =
>> diag([1,2,3])
ans =
1 0 0
0 2 0
0 0 3
>> [V,D]=eig(A)
V=
D=
16.1168 0 0
0 -1.1168 0
0 0 -0.0000
>> randn(2,4)
ans =
>> vligne=[27,31,40]
vligne =
27 31 40
>> Vcol=[36;88;95]
Vcol =
36
88
95
>> zeros(1,3)
ans =
0 0 0
>> ones(5,2)
ans =
1 1
1 1
1 1
1 1
1 1
B=
3 2 5
1 8 4
2 7 3
C=
0 2 9
4 6 1
3 8 5
>> V=[1;2;3]
V=
>> W=[0;5;2]
W=
>> B*C
ans =
23 58 54
44 82 37
37 70 40
>> B.*C
ans =
0 4 45
4 48 4
6 56 15
>> V.*W
ans =
10
F=
3 2 5 0
1 8 4 5
2 7 3 2
1 2 3 4
>> F(2,2)
ans =
8
>> F(:,3)
ans =
>> F(4,:)
ans =
1 2 3 4
ans =
4 5
ans =
2 3 7
1 4 8
1 3 2
p=[3 -5 2]
p=
3 -5 2
>> polyval(p,5)
ans =
52
>> x=[-1:0.1:2]
x=
Columns 1 through 6
Columns 7 through 12
-0.4000 -0.3000 -0.2000 -0.1000 0 0.1000
Columns 13 through 18
Columns 19 through 24
Columns 25 through 30
Column 31
2.0000
>> y=polyval(p,x)
y=
Columns 1 through 6
Columns 7 through 12
4.4800 3.7700 3.1200 2.5300 2.0000 1.5300
Columns 13 through 18
Columns 19 through 24
Columns 25 through 30
Column 31
4.0000
>> racines=roots(p)
racines =
1.0000
0.6667
1 0 -1
>> conv(p,p3)
ans =
3 -5 -1 5 -2
>> x1=[1 2 3 4]
x1 =
1 2 3 4
>> y1=[1 -1 2 0]
y1 =
1 -1 2 0
>> p4=polyfit(x1,y1,3)
p4 =
-1.6667 12.5000 -27.8333 18.0000
>> z=5*exp(-0.4*x1).*sin(7.5*y1)
z=
x=-2+5i
x=
-2.0000 + 5.0000i
>> a=real(x)
a=
-2
>> b=imag(x)
b=
>> m=abs(x)
m=
5.3852
>> c=conj(x)
c=
-2.0000 - 5.0000i
>> d=angle(x)
d=
1.9513
>> e=sqrt(2)
e=
1.4142
>> f=sign(-5)
f=
-1
>> x=0:0.02:5;
>> y=sin(x.^2);
>> z=cos(x.^2);
>> plot(x,y,'b',x,z,'r');grid;
>> legend('y','z');
>>
>> plot(x,y,'b',x,z,'r');grid;
>> legend('y','z');
0.8
0.6
0.4
0.2
y et z
-0.2
y
-0.4 z
-0.6
-0.8
-1
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
x
>> subplot(2,4,3)
>> plot(x,y)
>>
-1
0 5
g=
s+1
-------------
s^2 + 2 s + 1
h=
-10
-----------
(s+1) (s+2)
>> a=[0,1;-4,-4]
a=
0 1
-4 -4
>> b=[0;2]
b=
>> c=[1,0];
>> d=0
d=
>> fs=ss(a,b,c,d)
fs =
a=
x1 x2
x1 0 1
x2 -4 -4
b=
u1
x1 0
x2 2
c=
x1 x2
y1 1 0
d=
u1
y1 0
>> zpk(g)
ans =
(s+1)
-------
(s+1)^2
>> tf(h)
ans =
-10
-------------
s^2 + 3 s + 2