Mudanças entre as edições de "FIC MATLAB 2018-1/Aula-8"
Ir para navegação
Ir para pesquisar
(Criou página com '<syntaxhighlight lang=matlab class="mw-collapsible"> </syntaxhighlight>') |
|||
Linha 1: | Linha 1: | ||
<syntaxhighlight lang=matlab class="mw-collapsible"> | <syntaxhighlight lang=matlab class="mw-collapsible"> | ||
− | + | %-- 05-04-2018 19:05:52 --% | |
+ | % Variáveis lógicas | ||
+ | logical(17) | ||
+ | format compact | ||
+ | logical(7) | ||
+ | logical(23) | ||
+ | logical(-17) | ||
+ | logical(0) | ||
+ | var1 = 0 | ||
+ | var2 = true | ||
+ | var2 = false | ||
+ | doc logical | ||
+ | var3 = logical([]) | ||
+ | vetor = randi(10,1,8) | ||
+ | % Endereçamento lógico | ||
+ | vetor(3) | ||
+ | vetor(1,3) | ||
+ | vetor(logical(1)) | ||
+ | vetor(logical(0)) | ||
+ | vetor(logical(3)) | ||
+ | vetor(logical([0 0 1 0 0 0 0 0])) | ||
+ | vetor | ||
+ | vetor(logical([0 0 1 0 0 0 0 1])) | ||
+ | vetor([2 1 1 7 5 3 1 1]) | ||
+ | vetor([0 0 1 0 0 0 0 1]) | ||
+ | vetor(0) | ||
+ | vetor([false false true false false false false true]) | ||
+ | vetor(logical([0 0 1 0 0 0 0 1])) | ||
+ | vetor | ||
+ | vetor(logical([0 0 1 0 0 1])) | ||
+ | % Operadores relacionais | ||
+ | x = 1; | ||
+ | x > 3 | ||
+ | x < 10 | ||
+ | x ~= 12 | ||
+ | y = x == 3 | ||
+ | double(y) | ||
+ | y + 12 | ||
+ | y = true | ||
+ | y + 12 | ||
+ | n = -3:3 | ||
+ | n > 0 | ||
+ | n >= 0 | ||
+ | n(n >= 0) | ||
+ | m = [1 2 3] | ||
+ | % Comparação de vetoresx | ||
+ | n | ||
+ | m | ||
+ | n == m | ||
+ | m = [0 -2 8 1 1 0 3] | ||
+ | n | ||
+ | n == m | ||
+ | isequal(n,[1 3 5]) | ||
+ | isequal(n,m) | ||
+ | x | ||
+ | x = -2:11 | ||
+ | x2 = x(x > 0); | ||
+ | x2(x2 <= 9) | ||
+ | % Operadores lógicos | ||
+ | (x > 0) & (x <= 9) | ||
+ | x | ||
+ | (0 < x) & (x <= 9) | ||
+ | x((0 < x) & (x <= 9)) | ||
+ | x(0 < x & x <= 9) | ||
+ | x(0<x & x<=9) | ||
+ | 0 < x <= 9 | ||
+ | x | ||
+ | x(0>=x & x>9) | ||
+ | 0>=x & x>9 | ||
+ | 0>=x | x>9 | ||
+ | ~(0<x & x<=9) | ||
+ | m | ||
+ | n | ||
+ | xor(m,n) | ||
+ | 0<x & x<=9 | ||
+ | 0<x & x<=5 | ||
+ | xor(x>0, x<3) | ||
+ | x | ||
+ | x>0 | x<3 | ||
+ | x | ||
+ | x>0 | x<3 | ||
+ | x>0 & x<3 | ||
+ | xor(x>0, x<3) | ||
+ | ~xor(x>0, x<3) | ||
+ | % Strings | ||
+ | nome = 'Roberto' | ||
+ | nome == 'Roberto' | ||
+ | nome == 'Ronaldo' | ||
+ | strcmp(nome,'Roberto') | ||
+ | strcmp(nome,'Ronaldão') | ||
+ | nome == 'Ronaldão' | ||
+ | isequal(nome, 'Ronaldão') | ||
+ | isequal(nome, 'Roberto') | ||
+ | isequal(nome, 'roberto') | ||
+ | strcmpi(nome,'roberto') | ||
+ | strcmpi(nome,'rObERTo') | ||
+ | strcmpi(nome,'rObERT0') | ||
+ | double('e') | ||
+ | 'e'+0 | ||
+ | char(101) | ||
+ | a = 0.0 | ||
+ | whos | ||
+ | float(0.0) | ||
+ | doc find | ||
+ | % Comando find | ||
+ | x | ||
+ | find(x > 9) | ||
+ | x(find(x > 9)) | ||
+ | find([0 0 2 -1 7 3]) | ||
+ | find([0 0 2 -1 7 3] > 0) | ||
+ | find('Roberto') | ||
+ | find('Robert0') | ||
+ | find(['Roberto' 0]) | ||
+ | find([0 'Roberto']) | ||
+ | find('Roberto' == 'o') | ||
+ | indices = find('Roberto' == 'o'); | ||
+ | indices(1) | ||
+ | indices = find('Roberto' == 'o',1); | ||
+ | find('Roberto' == 'o',1) | ||
+ | find('Roberto' == 'o',2) | ||
+ | [a,b] = find('Roberto' == 'o',2) | ||
+ | [a,b] = find('Roberto' == 'o') | ||
+ | edit teste1.m | ||
+ | teste1 | ||
+ | doc publish | ||
+ | isnumeric('a') | ||
+ | isnumeric(a) | ||
+ | isnumeric(ans) | ||
</syntaxhighlight> | </syntaxhighlight> |
Edição atual tal como às 21h58min de 5 de abril de 2018
%-- 05-04-2018 19:05:52 --%
% Variáveis lógicas
logical(17)
format compact
logical(7)
logical(23)
logical(-17)
logical(0)
var1 = 0
var2 = true
var2 = false
doc logical
var3 = logical([])
vetor = randi(10,1,8)
% Endereçamento lógico
vetor(3)
vetor(1,3)
vetor(logical(1))
vetor(logical(0))
vetor(logical(3))
vetor(logical([0 0 1 0 0 0 0 0]))
vetor
vetor(logical([0 0 1 0 0 0 0 1]))
vetor([2 1 1 7 5 3 1 1])
vetor([0 0 1 0 0 0 0 1])
vetor(0)
vetor([false false true false false false false true])
vetor(logical([0 0 1 0 0 0 0 1]))
vetor
vetor(logical([0 0 1 0 0 1]))
% Operadores relacionais
x = 1;
x > 3
x < 10
x ~= 12
y = x == 3
double(y)
y + 12
y = true
y + 12
n = -3:3
n > 0
n >= 0
n(n >= 0)
m = [1 2 3]
% Comparação de vetoresx
n
m
n == m
m = [0 -2 8 1 1 0 3]
n
n == m
isequal(n,[1 3 5])
isequal(n,m)
x
x = -2:11
x2 = x(x > 0);
x2(x2 <= 9)
% Operadores lógicos
(x > 0) & (x <= 9)
x
(0 < x) & (x <= 9)
x((0 < x) & (x <= 9))
x(0 < x & x <= 9)
x(0<x & x<=9)
0 < x <= 9
x
x(0>=x & x>9)
0>=x & x>9
0>=x | x>9
~(0<x & x<=9)
m
n
xor(m,n)
0<x & x<=9
0<x & x<=5
xor(x>0, x<3)
x
x>0 | x<3
x
x>0 | x<3
x>0 & x<3
xor(x>0, x<3)
~xor(x>0, x<3)
% Strings
nome = 'Roberto'
nome == 'Roberto'
nome == 'Ronaldo'
strcmp(nome,'Roberto')
strcmp(nome,'Ronaldão')
nome == 'Ronaldão'
isequal(nome, 'Ronaldão')
isequal(nome, 'Roberto')
isequal(nome, 'roberto')
strcmpi(nome,'roberto')
strcmpi(nome,'rObERTo')
strcmpi(nome,'rObERT0')
double('e')
'e'+0
char(101)
a = 0.0
whos
float(0.0)
doc find
% Comando find
x
find(x > 9)
x(find(x > 9))
find([0 0 2 -1 7 3])
find([0 0 2 -1 7 3] > 0)
find('Roberto')
find('Robert0')
find(['Roberto' 0])
find([0 'Roberto'])
find('Roberto' == 'o')
indices = find('Roberto' == 'o');
indices(1)
indices = find('Roberto' == 'o',1);
find('Roberto' == 'o',1)
find('Roberto' == 'o',2)
[a,b] = find('Roberto' == 'o',2)
[a,b] = find('Roberto' == 'o')
edit teste1.m
teste1
doc publish
isnumeric('a')
isnumeric(a)
isnumeric(ans)