FIC MATLAB 2019-1/Aula-7

De MediaWiki do Campus São José
Ir para navegação Ir para pesquisar
A versão imprimível não é mais suportada e pode ter erros de renderização. Atualize os favoritos do seu navegador e use a função de impressão padrão do navegador.
% Polinômios
% Representação a partir de vetores
f = [1 -3 8 0 1]
format compact
% Cálculo de valor
polyval(f,0)
polyval(f,1)
polyval(f,2)
fx = polyval(f,-20:0.1:20);
plot(-20:0.1:20,fx)
x = -20:0.1:20;
fx = polyval(f,x);
plot(x,fx)
-20:0.1:20
f2 = x.^4 - 3*x.^3 + 8*x.^2 + 1
plot(x,f2)
% Poly
g = poly([3 2])
g = poly([2 3])
% Roots
h = roots([1 -5 6])
h
g = poly(roots(1 -5 6))
g = poly(roots([1 -5 6]))
x = 0:0.1:4;
plot(x,polyval(g,x))
grid on
% Multiplicação de polinômios (chuveirinho)
conv([1 0 1],[1 -5 6])
% Divisão de polinômios
deconv([1 -5 7 -5 6],[1 0 1])
doc deconv
[q,r] = deconv([1 -5 7 -5 6],[1 0 1])
conv(q,[1 0 1]) + r
% Derivada
p = [3 0 2 0 1 5];
polyder(p)
% Integral
polyint([15 0 6 0 1])
integral = polyint([15 0 6 0 1])
polyval(integral,[1 8])
diff(polyval(integral,[1 8]))
integral = polyint([15 0 6 0 1])
integral = polyint([15 0 6 0 1],67)
integral = polyint([15 0 6 0 1],99)
% Números aleatórios
% Valores inteiros uniformemente distribuídos
randi([3 8],1,15)
% Valores uniformemente distribuídos
rand(5)
3*rand(5)
+1
3*rand(5)+1
3*rand(1,10)+1
3*rand(1,9)+1
% Valores normalmente distribuídos
randn(1,9)
% Histograma
hist(randi([3 8],1,15))
hist(randi([3 8],1,15),5)
hist(randi([3 8],1,15),6)
hist(randi([3 8],1,15),5)
hist(randi([3 8],1,15),10)
randi([3 8],1,15)
x = [0 2 9 2 5 8 7 3 1 9 4 3 5 8 10 0 1 2 9 5 10];
hist(x)
x = randn(1,1000);
hist(x)
hist(x,100)
x = rand(1,1000);
hist(x,100)
x = rand(1,100000);
hist(x,100)
x = rand(1,10000000);
hist(x,100)
x = randn(1,10000000);
hist(x,100)
A = randn(500,500,3);
imshow(A)
hist(x,100)
A = randn(500,500,3);
imshow(A)
figure; while(1); imshow(randn(500,500,3)); pause(0.2); end
figure; while(1); imshow(randn(500,500,3)); pause(0.05); end
figure; while(1); imshow(randn(500,500,3)); pause(0.01); end
figure; while(1); imshow(randn(500,500,3)); pause(0.005); end