FIC MATLAB 2017-2/Aula-3

De MediaWiki do Campus São José
Ir para navegação Ir para pesquisar
%-- 14-09-2017 19:09:16 --%
edit
% Operações com matrizes
A = [1 2; 3 4]
B = [5 6; 7 99]
A + B
format short
format compact
A
B
A + B
A - B
C = [0 1; 10 0]
A + B + C
D = [1 2 3; 5 4 3]
A + D
A*B
A
B
A*B
A*D
A
D
A*D
D*A
u = 1:4
v = 5:8
u * v
u * v.'
u.' * v
A
B
A .* B
u
v
u .* v
u * v
u ./ v
A / B
A
B
A ./ B
A
A^2
A*A
D
D^2
D*D
A^10
A
A.^2
cos(10)
exp(3)
A
cos(A)
cos(1)
cos(2)
E = [1 10; 100 1000]
log10(E)
A - 1
A
A + 5
10*A
A / 3
A ./ 3
A .+ 5
A + 5
u
v
3*cos(u) + v
u
sum(u)
prod(u)
u
v
u .* v
sum(u .* v)
u * v'
dot(u, v)
A
sum(A)
doc sum
sum(A, 2)
A
sum(A)
sum(sum(A))
sum(sum(sum(A)))
prod(A)
prod(A, 2)
lookfor factorial
factorial(12)
1:12
12:-1:1
prod(1:12)
u
min(u)
w = [20 1 3 2 -4 2]
min(w)
max(w)
E
min(E)
min(E, 2)
min(E')
E'
min(E')'
min(min(E))
max(max(E))
w
u
v1 = [3 4]
norm(v1)
u
norm(u)
mean(u)
u
sum(u) / length(u)
A
det(A)
inv(A)
u
var(u)
reshape(1:20, 4, 5)
reshape(1:20, 5, 4)'
reshape((1:20)', 4, 5)
reshape(1:20, 5, 4)'
% Comandos de plotagem
r = [1 35 8 42 (99-1)];
r
w = [-1 4 8 8 0]
plot(r,w)
r = [1 8 35 42 (99-1)];
plot(r,w)
r
w
t = 0:0.1:2*pi;
x = cos(t);
t
x
plot(t,x)
stem(t,x)
bar(t,x)
stairs(t,x)
plot(t,x)
length(t)
t = 0:0.5:2*pi;
length(t)
x = cos(t);
plot(t,x)
t = 0:0.1:2*pi;
x = cos(t);
plot(t,x)
t = 0:0.5:2*pi;
length(t)
length(x)
plot(t,x)
plot(x)
plot(t,x)
t = 0:0.1:2*pi;
plot(t,x)
plot(x)
y = sin(x);
t
x
y = sin(t);
y
plot(t,x)
hold on
plot(t,y)
plot(t,y+x)
hold off
plot(t,y+x)
grid on
doc grid
grid minor
axis([0 6.2 -1.5 1.5])
xlim([2 4])
xlabel('Tempo')
ylabel('Amplitude')
title('Coelhinhos')
hold on
plot(t,y)
legend('Fêmea','Macho')
doc plot
hold off
plot(t,y)
plot(t,y,'r')
plot(t,y,'y')
plot(t,y,'k')
plot(t,y,'m')
plot(t,y,'c')
plot(t,y,'o')
plot(t,y,'p')
plot(t,y,'^')
plot(t,y,'m*')
title('Hello Kitty')
plot(t,y,'m')
plot(t,y,'w')
grid minor
plot(t,y,'w','LineWidth',4)
grid minor
plot(t,y,'m:')
plot(t,y,'m--')
legend('Seno')
plot(t,y,'m--p')
plot(t,y,'m--h')
legend('Seno')