FIC MATLAB 2017-1/Aula-3

De MediaWiki do Campus São José
Ir para navegação Ir para pesquisar
%-- 13-03-2017 19:18:41 --%
% Voltando à plotagem da aula anterior
x = linspace(0,4*pi,1000);
y = sin(x);
plot(x,y)
grid on
% Exemplo de linspace
linspace(2,8,5)
% Construindo outra curva
z = cos(x);
hold on
stem(x,z)
help hold
plot(x,z)
xlabel('Valores de x')
ylabel('cos(x) e sen(x)')
ylabel('cos(x) e sen(\omega)')
title('Gráfico da aula de FIC MATLAB')
axis([0 4*pi -1.1 1.1])
clc
% Outros comandos sobre Plot
figure
figure(1)
figure(2)
figure(1)
figure(2)
stem(ans)
plot(sin(x))
% Plotando mais d eum gráfico em uma figura
y = sin(x);
z = cos(x);
figure
subplot(2,1,1)
plot(x,y)
xlabel('x')
ylabel('sin(x)')
grid on
title('Plot de um seno')
subplot(2,1,2)
plot(x,z)
xlabel('x')
ylabel('cos(x)')
grid on
title('Plot de um cosseno')
% Adicionando uma legenda
figure(1)
doc legend
legend('sen(x)','cos(x)','Ligando os pontos')
close all
linspace(2,8,5)
linspace(2,9,5)
edit nova_script.m
nova_script
doc fplot
clc
% Atributos
y = sin(x);
plot(x,y,'--')
plot(x,y,'-.')
plot(x,y,':')
plot(x,y,'--k')
plot(x,y,'--r')
plot(x,y,'--y')
plot(x,y,'--m')
plot(x,y,'--g')
plot(x,y,'--k')
plot(x,y,'--k*')
plot(x,y,'--k^')
edit meuscript.m
plot(x,y,'--k^')
close all
plot(x,y,'--k^')
clear all
% Endereçamento de vetores e matrizes
Lin = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Lin = [0 1 2 3 4 5 6 7 8 9]
Lin = [0 1 2 3 4.2 5 6 7 8 9]
Lin = [0 1 2 3 4 5 6 7 8 9]
Col = [10; 11; 12; 13; 14; 15; 16; 17; 18; 19]
Lin = 0:1:9
Lin = 0:9
Col = [10:19]'
Col = (10:19)'
Mat = [0 1 2 3; 4 5 6 7; 8 9 10 11]
Mat = [0 1 2 3
4 5 6 7
8 9 10 11]
0:89
% Comando reshape
Mat = reshape(0:89, 9, 10)
Mat = reshape(0:89, 10, 9)'
A = [1 2 3; 4 5 6]
reshape(A, 3, 2)
A
A'
A
reshape(A, 3, 2)
reshape(A, 3, [])
Mat = reshape(0:89, 10, [])'
Mat = reshape(0:89, 5, [])'
size(Mat)
Mat = reshape(0:89, [], 18)'
A
reshape(A, 3, 5)
reshape(A, 4, 2)
reshape(A, 4, 1)
numel(A)
A
% Comando repmat
repmat(A, 2, 3)
numel(ans)
repmat(A, 2, 3)
numel ans
Lin
Col
Mat
Mat = reshape(0:89, 10, 9)'
% Indexação de vetores e matrizes
Lin
Lin_1 = Lin(1)
Col_3 = Col(3)
Mat_2_4 = Mat(2, 4)
Mat_6 = Mat(6)
Mat(12)
Lin
Lin_2a5 = Lin(2:5)
Col
Col_1a7 = Col(1:7)
Mat
Mat_3_5a8 = Mat(3, 5:8)
Mat_3a7_8 = Mat(3:7, 8)
Mat_3_T = Mat(3, [])  % Será que funciona?
Mat_3_T = Mat(3, :)
Mat_T_5 = Mat(:, 5)
Mat_T_5 = Mat(:, :)
Mat_T_5 = Mat(:, 5)
Lin
Lin_3aE = Lin(3:end)
Col
Col_5aE = Col(5:end)
Mat
Mat_5aE_4aE = Mat(5:end, 4:end)
Lin
Lin_384 = Lin([3 8 4])
Lin(3:5)
Lin([3 4 5])
Col
Col_922 = Col([9 2 2])
Mat_74_8 = Mat([7 4], 8)
Mat_34_86 = Mat([3 4], [8 6])
Mat
% Indexação do lado esquerdo do sinal de igualdade
Mat6 = Mat(6)
Mat(6) = 18
Mat(6:8, 7:end) = 0
Mat(2:2:6, 1:4) = 1
A = [321 234 312; 234 234 123]
Mat(1:2, 8:end) = A
% Removendo linhas ou colunas
Mat(:, [2 4]) = []
Mat