% Historico de comandos da primeira aula
a = 10
b = 2;
c = [ 1 2 3 ]
d = [ 1; 2; 3 ]
d
D
D = 1:10
E = 1:2:10
E.'
E'
a * b
a * c
c * E
c
E
c * c
c
c .* c
home
clear
a
a = ones( 3 )
a = ones( 3, 1 )
a = ones( 1, 3 )
a = ones( [2 3] )
a = ones( [1 3 2] )
a = ones( [2 3] )
a(:)
a = [ 1 3 5; 2 4 6 ]
b = [ 1 2 3; 4 5 6 ]
b = [ 1 2; 3 4; 5 6 ]
b = [ 1 2; 3 4; 5 6 ].'
c = [ 1; 2 3; 4 5; 6 ]
c = [ [1; 2] [3; 4] [5; 6] ]
whos
1i
c = c*1i
whos
b(3)
b(3) = 1i
whos
clear
home
a
a(5,3) = 1
a(5;3) = 1
help save
help ones
home
whos
size( a )
b = size( a )
length( a )
max( b )
help max
a
b
a = [ 1 3 5; 2 4 6 ]
sort( a )
sort( a,1,'descend' )
sort( a,2,'descend' )
home
clear
edit piexp
clear
N = 100;
n = 0;
for i = 1 : N
x1 = rand;
x2 = rand;
if ( x1^2 + x2^2 )<=1
n = n + 1;
end
end
PIexp = 4 * n / N
piexp
home
piexp
PIs = [ 3.1184 3.1484 3.1084 3.1415 3.1436 3.1256 3.1400 ...
3.1356 3.1592 3.1336 3.1620 3.1392 3.1416 3.1408 3.1472 3.1800 3.1636 ];
mean( PIs )
std( PIs )
std( PIs ) / sqrt( length(PIs) )
home
N = 1e4;
N = 5
rand(2,N).^2
sum( rand(2,N).^2, 1 )
sum( rand(2,N).^2, 1 )<=1
mean( sum( rand(2,N).^2, 1 )<=1 )
4*mean( sum( rand(2,N).^2, 1 )<=1 )
N=1e4
4*mean( sum( rand(2,N).^2, 1 )<=1 )
std( 4*mean( sum( rand(2,N,5e2).^2, 1 )<=1 ) )
PIs2 = ( 4*mean( sum( rand(2,N,5e2).^2, 1 )<=1 ) );
whos
plot( PIs, '*' )
plot( PIs2, '*' )
clear PIs2
PIs2(:,1) = ( 4*mean( sum( rand(2,N,5e2).^2, 1 )<=1 ) );
whos
figure, plot( PIs2, '*r' )
help find
ind_plus = find( PIs2>pi );
ind_menos = find( PIs2<pi );
figure, plot( PIs2(ind_plus), 'xr' )
figure, plot( PIs2(ind_plus), 'xr' ), hold on, plot( PIs2(ind_menos), 'xb' )
figure, plot( ind_plus, PIs2(ind_plus), 'xr' ), hold on, plot( ind_menos, PIs2(ind_menos), 'xb' )
figure, plot( ind_plus, PIs2(ind_plus), 'xr', ind_menos, PIs2(ind_menos), 'xb' )
