Académique Documents
Professionnel Documents
Culture Documents
EXERCCIOS AULA II
Introduo ao Matlab
OURO BRANCO MG
2015
C= 0 5 10 15 10 5 0
-1 -2 -3 -4 -5 -6 -7
Atravs das matrizes acima, determine a seguir utilizando os comandos j
mencionados.
D =[ 4 5 6 7]
E =[ 7 6 5 4 ]
F=4 5 6 7
7 6 5 4
G=4 7
5 6
6 5
7 4
H =12
15
18
21
I=5
-6
J = 0 5 10
-1 -2 -3
K = 0 25 100
1 4 9
L = 0 24 99
2 5 10
M = 0 -24 -99
-2 -5 -10
>> A=[1:7]
B=[3:3:21]
C=[0 5 10 15 10 5 0;-1 -2 -3 -4 -5 -6 -7]
A=1 2 3 4 5 6 7
B = 3 6 9 12 15 18 21
C = 0 5 10 15 10 5 0
-1 -2 -3 -4 -5 -6 -7
>> D=A(4:7)
D= 4 5 6
>> E=sort(D,'descend')
E =7 6 5 4
>> F = [D; E]
F=4 5 6
7 6 5
7
4
>> G = F'
G=4 7
5 6
6 5
7 4
>> H = B(4:7)
H = 12 15 18
21
>> H = H'
H =12
15
18
21
>> C0 = C(1,6)
C0 = 5
>> C1 = C(2,6)
C1 = -6
>> I = [C0 C1]
I = 5 -6
>> I = I
>> I=I'
I=5
-6
>> J = C(1:2,1:3)
J = 0 5 10
-1 -2 -3
>> K = J.*J
K = 0 25 100
1 4 9
>> Z=[0 -1 -1;1 1 1]
Z = 0 -1 -1
1 1 1
>> L = K+Z
L = 0 24 99
2 5 10
>> M = L.*(-1)
M = 0 -24 -99
-2 -5 -10
2) Resolva o seguinte sistema de equaes lineares:
2x1 + 1; 5x2 + x3 = 13; 20;
x1 + 6x2 - 2x3 = 21; 64;
2x2 + 4x3 = 26; 62:
>> x2 = [mat(:,1),vet,mat(:,3)]
x2 = 2.0000 13.2000 1.0000
1.0000 21.6400 -2.0000
2.0000 26.6200
0
>> raizx2=det(x2)/det(mat) %comando para acharmos o valor da 2incgnita x2
raizx2 = 18.5100
>> x3=[mat(:,1),mat(:,2),vet]
x3 = 2.0000 1.5000 13.2000
1.0000 6.0000 21.6400
2.0000 4.0000 26.6200
>> raizx3=det(x3)/det(mat) %comando para acharmos o valor da 3incgnita x3
raizx3 = 32.8550
3) Crie um vetor A com 50 elementos aleatrios e a partir deste vetor crie um vetor B
obedecendo os seguintes critrios:
a) Conter somente os valores maiores que 0,5;
>> A=rand(1,50)
A = Columns 1 through 9
0.8147 0.9058 0.1270
Columns 10 through 18
0.9649 0.1576 0.9706
Columns 19 through 27
0.7922 0.9595 0.6557
Columns 28 through 36
0.3922 0.6555 0.1712
Columns 37 through 45
0.6948 0.3171 0.9502
Columns 46 through 50
0.4898 0.4456 0.6463
0.9134
0.6324
0.0975
0.2785
0.5469
0.9575
0.9572
0.4854
0.8003
0.1419
0.4218
0.9157
0.0357
0.8491
0.9340
0.6787
0.7577
0.7431
0.7060
0.0318
0.2769
0.0462
0.0971
0.8235
0.0344
0.4387
0.3816
0.7655
0.7952
0.1869
0.7094
0.7547
>> B = A+0.5
B = Columns 1 through 9
1.3147 1.4058 0.6270 1.4134 1.1324 0.5975 0.7785 1.0469 1.4575
Columns 10 through 18
1.4649 0.6576 1.4706 1.4572 0.9854 1.3003 0.6419 0.9218 1.4157
Columns 19 through 27
1.2922 1.4595 1.1557 0.5357 1.3491 1.4340 1.1787 1.2577 1.2431
Columns 28 through 36
0.8922 1.1555 0.6712 1.2060 0.5318 0.7769 0.5462 0.5971 1.3235
Columns 37 through 45
1.1948 0.8171 1.4502 0.5344 0.9387 0.8816 1.2655 1.2952 0.6869
Columns 46 through 50
0.9898 0.9456 1.1463 1.2094 1.2547
>> B=B'
B = 1.3147
1.4058
0.6270
1.4134
1.1324
0.5975
0.7785
1.0469
1.4575
1.4649
0.6576
1.4706
1.4572
0.9854
1.3003
0.6419
0.9218
1.4157
1.2922
1.4595
1.1557
0.5357
1.3491
1.4340
1.1787
1.2577
1.2431
0.8922
1.1555
0.6712
1.2060
0.5318
0.7769
0.5462
0.5971
1.3235
1.1948
0.8171
1.4502
0.5344
0.9387
0.8816
1.2655
1.2952
0.6869
0.9898
0.9456
1.1463
1.2094
1.2547
>> B=sort(B,'descend')
B = 1.4706
1.4649
1.4595
1.4575
1.4572
1.4502
1.4340
1.4157
1.4134
1.4058
1.3491
1.3235
1.3147
1.3003
1.2952
1.2922
1.2655
1.2577
1.2547
1.2431
1.2094
1.2060
1.1948
1.1787
1.1557
1.1555
1.1463
1.1324
1.0469
0.9898
0.9854
0.9456
0.9387
0.9218
0.8922
0.8816
0.8171
0.7785
0.7769
0.6869
0.6712
0.6576
0.6419
0.6270
0.5975
0.5971
0.5462
0.5357
0.5344
0.5318
4) Os trs vrtices de um tringulo esto em A (6,-1,2), B(-2,3,-4) e C(-3,1,5).
Determine o vetor perpendicular ao plano no qual o tringulo est localizado.
Tambm determine o ngulo BCA no vrtice A.
>> A=[6 -1 2]
A = 6 -1 2
>> B=[-2 3 -4]
B = -2 3 -4
>> C=[-3 1 5]
C = -3 1 5
>> AB=B-A
AB = -8 4
>> AC=C-A
AC = -9 2
-6
3
prodoutodvetorial = 24 78 20
>> x=sqrt((-8*-8)+(4*4)+(-6*-6))
x = 10.7703
>> y=sqrt((-9*-9)+(2*2)+(3*3))
y = 9.6954
>> produtoescalar = dot(x,y)
produtoescalar = 104.4222
>> angulobcanoverticea=acos(produtoescalar/x*y)
angulobcanoverticea = 0 + 5.2364i
5) Declare a matriz X (X=[6 2 45; 65 32 9; 3 8 1]) no matlab e determine:
>> X=[6 2 45; 65 32 9; 3 8 1]
X = 6 2 45
65 32 9
3 8 1
a) Um vetor Y que tenha o valor mnimo das trs primeiras colunas;
>> Y=min(X)
Y=3 2 1
b) A soma dos elementos de Y;
b) >> y=sum(Y)
y=6
c) Um vetor Z que tenha o valor mximo das trs primeiras linhas;
>> Z=max(X)
Z = 65 32 45
d) O produtrio dos elementos do vetor Z;
>> z=prod(Z)
z = 93600
e) Calcule o mdulo dos elementos de cada linha;