FIC MATLAB 2017-2/Aula-6

De MediaWiki do Campus São José
Ir para navegação Ir para pesquisar
%-- 26-09-2017 19:06:22 --%
floor(1.2)
floor(1.9)
floor(1)
floor(2)
ceil(2.8)
ceil(2.01)
ceil(2)
round(5.75)
round(5.5)
round(4.5)
round(14)
sign(1230
sign(123)
sign(-17)
sign(-17.43)
sign(0)
floor([1.2 1.7 2 3 16.4])
clear
clc
edit
% Concatenação de vetores e matrizes
u = [1 2 3]
v = [4 5 60]
w = [u v]
w = [u, v]
w = [u, v, 10:20]
w = [u v 10 : 20]
z = [v; u]
A = [u v; 2*v v+u]
u]
u
[u, [u v]]
[u; [u v]]
u
v2 = [1 2 3 4]
[u; v2]
A = eye(3)
B = randn(3, 4)
C = ones(2, 7)
[A B; C]
% repmat
A = [1 2; 3 4]
[A A A; A A A]
repmat(A, 2, 3)
v = (1:1:10)'
repmat(v, 1, 7)
repmat(6, 4, 4)
% Reshape
A = [
A = [1 2 3 4; 5 6 7 8; 9 10 11 12]
reshape(A, 2, 6)
format compact
A'
reshape(A', 2, 6)
reshape(A', 6, 2)'
A
reshape(A, 2, 6)
reshape(A, [], 6)
reshape(A, 2, [])
u
v
v = [4 5 60]
clc
u
v
[u; v]
reshape([u; v], 1, [])
w = zeros(1, 6)
w(1:2:end) = u
w(2:2:end) = v
reshape(1:20, 4, [])
reshape(1:20, 5, 4)'
% Comandos sort e unique
x = randn(1,10)
x = randn(1,8)
x = randn(1,6)
sort(x)
x
sort(x)
[x_ordenado, i]= sort(x)
x(i)
y = randn(1,6)
x
y
[x_ordenado, i] = sort(x);
x_ordenado
y(i)
max(x)
[valor,i] = max(x)
x
doc max
help max
doc max
doc
lookfor integral
a = [1 2 4 3 2 6 6 5]
unique(a)
b = [7 9 99 7 1 2]
a
b
union(a,b)
intersect(a,b)
setdiff(a,b)
unique(a)
unique(b)
setdiff(b,a)
setdiff(b,b)
setxor(a,b)
setdiff(union(a,b),intersect(a,b))
union(setdiff(a,b),setdiff(b,a))
[ 3     4     5     6     7     9    99]
intersect(3:3:200, 5:5:200)
15:15:200
clc
clear all
% Polinônios
p = [7 5 -2 -6]
q = [2 0 7]
polyval(q, 5)
polyval(q, [1 5 5 6])
roots(p)
r = [1 -5 6]
roots(r)
eval(r, [2 3])
polyval(r, [2 3])
r1 = poly([2 3])
roots(poly([2 3]))
conv(q, r)
conv([1 -3], [1 -2])
f = [3 5 7]
g = [1 2]
[q, r] = deconv(f, g)
conv(q, g)
conv(q, g) + r
tic; [q, r] = deconv(f, g); toc
tic; conv(f, g); toc
polyder(f)
polyint(f)
polyint(f, 17)
% Trabalhando com texto
figure
plot(f)
f
roots(f)
plot(polyval(f,-10:0.1:10))
x = -10:0.1:10;
plot(x,polyval(f,x))
title('Polinômio')
a = 'texto'
a = 'texto oi'
a(1)
a(1:5)
a(1:2:5)
a'
b = 'bonito'
[a b]
[a, ' ', b]
a
b
[a; b]
length(a)
length(b)
[a; b, '  ']
a * 2
a + 1
a+0
a
97-65
a-32
num2str(a-32)
char(a-32)
plot(x,polyval(f,x))
nome = 'polinomio';
title(['O plot é sobre: ' nome])
% Entrada/saída de dados
resposta = input('Digite seu nome: ');
Roberto
'Roberto'
resposta = diego
resposta = input('Digite seu nome: ','s');
Roberto
respsota
resposta
resposta = input('Digite seu numero: ');
168
resposta
resposta = input('Digite seu numero: ')
168
resposta1 = input('Digite seu numero: ')
168
resposta2 = input('Digite seu numero: ','s')
168
double(resposta2)
a = 'Voce digitou 168'
disp('Voce digitou 168')
resposta
disp(['Voce digitou ' resposta])
resposta = 19848165;
disp(['Voce digitou ' resposta])
size('Voce digitou ')
size(resposta)
resposta = 116
disp(['Voce digitou ' resposta])
disp(['Voce digitou ' num2str(resposta)])
plot(x,polyval(f,x))
title(['O valor da funcao é ' num2str(resposta)])
disp(116)
disp([116 117])
['O valor da funcao é ' num2str(resposta)]
['O valor da funcao é ' resposta]
str2num('168')
str2num('a')
'168' + 1
str2num('168') + 1
resposta2 = input('Digite seu numero: ')
16564654
resposta2 = input('Digite seu numero: ')