Compte Rendu TP1 Matlab
Compte Rendu TP1 Matlab
Compte Rendu TP1 Matlab
Par :
MAAMERIA Meriem Feriel
Application 1 :
-8:0.25:-5
ans =
Columns 1 through 12
Column 13
-5.0000
>> 3:0.1:15
ans =
Columns 1 through 12
Columns 13 through 24
Columns 25 through 36
Columns 49 through 60
Columns 61 through 72
Columns 73 through 84
Columns 85 through 96
Column 121
15.0000
>> -pi:100:pi
ans =
-3.1416
Application 2:
A=[1 2 3;2 3 1;3 1 2]
A=
1 2 3
2 3 1
3 1 2
ans =
2 3 1
3 1 2
ans =
2 1
3 2
ans =
2 3
3 1
>> A(:)
ans =
>> A(5)
ans =
3
>> C=[A,zeros(3,2);zeros(2,3),eye(2)]
C=
1 2 3 0 0
2 3 1 0 0
3 1 2 0 0
0 0 0 1 0
0 0 0 0 1
Application 3 :
ones(6,4)
ans =
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
>> magic(5)
ans =
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
>> rand(4,2)
ans =
0.8147 0.6324
0.9058 0.0975
0.1270 0.2785
0.9134 0.5469
>> eye(15)
ans =
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
>> x=linspace(1,30,50)
x=
Columns 1 through 12
Columns 25 through 36
Columns 37 through 48
Columns 49 through 50
29.4082 30.0000
>> length(x)
ans =
50
A=
6 8 8 15
12 10 6 12
18 16 8 14
4 3 7 9
>> A(3,3)
ans =
>> A(1,:)
ans =
6 8 8 15
>> A(:,2)
ans =
8
10
16
>> A(1:2,3:4)
ans =
8 15
6 12
>> A([1,3],[2,4])
ans =
8 15
16 14
>> A(2,:)=[]
A=
6 8 8 15
18 16 8 14
4 3 7 9
>> size(A)
ans =
3 4
Application 5 :
>> A=[1 3 4 6;2 1 3 4;-3 2 1 3;8 -3 2 1]
A=
1 3 4 6
2 1 3 4
-3 2 1 3
8 -3 2 1
>> A'
ans =
1 2 -3 8
3 1 2 -3
4 3 1 2
6 4 3 1
>> det(A-2.i)
ans =
-13.0000 -10.0000i
>> reshape(A(:),size(A))
ans =
1 3 4 6
2 1 3 4
-3 2 1 3
8 -3 2 1
>> A(3,4)
ans =
>> A(2,:)
ans =
2 1 3 4
>> A(:,3)
ans =
1
2
>> A(2:3,2:3)
ans =
1 3
2 1
>> A([1,2],[2,3])
ans =
3 4
1 3
>> A(3,:)=[]
A=
1 3 4 6
2 1 3 4
8 -3 2 1
Application 7 :
x=-3:0.1:3;
f=sin(x)+sqrt(x.^2+1);
plot(x,f)
g=cos(x)+2*x/x.^2+1;
hold on
plot(x,g,'y')
Figure I
Application 8 :
fplot('exp(-x/25)',[0,10]);
Figure II
fplot('cos(x/10)',[0,10]);
Figure III
x=0:0.1:10;
f=exp(-x/25);
g=cos(x/10);
plot(x,f,x,g)
Figure IV
Application 9 :
x1=[0:0.01:2];
f1=10*ones(size(x1));
x2=[2.01:0.01:4.99];
f2=zeros(size(x2));
x3=[5:0.01:7];
f3=-3*ones(size(x3));
f=[f1,f2,f3];
x=[x1,x2,x3];
plot(x,f),xlabel('x'),ylabel('y')
Figure V
Application 10 :
x=-2:0.1:2;
f1=1+x.^2/sqrt(x.^3+3);
plot(x,f1)
f2=x.^2;
hold on
plot(x,f2,'r')
Figure VI
Application 11 :
f=inline('sin(x+y)+1-1/40*x.^2+exp(-y.^2)','x','y')
x=-6:.2:9
y=-4:.2:4
[x,y]=meshgrid(x,y);
surf(x,y,f(x,y))
>> Untitled
f=
Inline function:
f(x,y) = sin(x+y)+1-1/40*x.^2+exp(-y.^2)
x=
Columns 1 through 12
Columns 13 through 24
Columns 25 through 36
-1.2000 -1.0000 -0.8000 -0.6000 -0.4000 -0.2000 0 0.2000 0.4000
0.6000 0.8000 1.0000
Columns 37 through 48
Columns 49 through 60
Columns 61 through 72
Columns 73 through 76
y=
Columns 1 through 12
Columns 13 through 24
Columns 25 through 36
Columns 37 through 41
Application13:
>> A=[6 1 -5;2 2 3;4 -9 7]
A=
6 1 -5
2 2 3
4 -9 7
>> B=[6;7;10]
B=
10
>> x=inv(A)*B
x=
1.7166
0.3797
0.9358
A=
1 2 3 4
2 3 4 1
-2 4 -5 2
8 1 -1 3
>> B=[2;0;3;4]
B=
>> x=inv(A)*B
x=
0.2000
0.1000
-0.3385
0.6538
Conclusion:
A partir de ce TP on a conclu que nous pouvons utiliser ce logiciel dans :