%% Historico de comandos 8a aula
mkdir aula_8
cd aula_8
help xlsread
home
[ DN, DT, RAW ] = xlsread('Dados_carros.xls')
[ DN, DT, RAW ] = xlsread_zw('Dados_carros.xls')
clear
home
[ DN, DT, RAW ] = xlsread('Dados_carros.xls',2)
[ DN, DT, RAW ] = xlsread('Dados_carros.xls')
DN
iok = find( isfinite(DN(:,1)) )
t = DN(iok,1);
v = DN(iok,2)/3.6;
figure, plot( sqrt(t), v, '*' )
figure, plot( sqrt(t), v*3.6, '*' )
vlim = 100/3.6;
ifit = find( v<=vlim );
A = polyfit( sqrt(t(ifit)), v, 1 )
size( sqrt(t(ifit)) )
size( v )
A = polyfit( sqrt(t(ifit)), v(ifit), 1 )
figure
subplot(3,1,1:2)
plot( sqrt(t), v*3.6, '*' )
hold on
plot( sqrt(t), polyval( A, sqrt(t) ), '-r' )
plot( sqrt(t), 3.6*polyval( A, sqrt(t) ), '-r' )
plot( sqrt(t(ifit)), v(ifit)*3.6, 'ok' )
subplot(3,1,3)
plot( sqrt(t), 3.6*(v-polyval(A,sqrt(t))), '*' )
clear
nada = 'alfa'
isfinite( nada )
ischar( nada )
nada2 = [ 10 20 30 40 ]
ischar( nada2 )
isfinite( nada2 )
isnumeric( nada )
isnumeric( nada2 )
clear
home
DT
DT(1,2)
nada = DT(1,2)
whos
nada2 = DT{1,2}
whos
close all
2^(3/2)
2^3/2
close all
clear
home
help fft
Fs = 1000;                    % Sampling frequency
T = 1/Fs;                     % Sample time
L = 1000;                     % Length of signal
t = (0:L-1)*T;                % Time vector
% Sum of a 50 Hz sinusoid and a 120 Hz sinusoid
x = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);
y = x + 2*randn(size(t));     % Sinusoids plus noise
plot(Fs*t(1:50),y(1:50))
title('Signal Corrupted with Zero-Mean Random Noise')
xlabel('time (milliseconds)')
figure, plot( y )
y = x + 0.1*randn(size(t));     % Sinusoids plus noise
figure, plot( y )
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2);
% Plot single-sided amplitude spectrum.
plot(f,2*abs(Y(1:NFFT/2)))
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
x = 1.7*sin(2*pi*50*t) + .5*sin(2*pi*120*t);
y = x + 0.1*randn(size(t));     % Sinusoids plus noise
close all
figure, plot( diff(f), '*' )
mean( diff(f) )
NFFT
mean( diff(f) )
f(1:5)
close all
clear
home
whos
Pot = abs(Y).^2;
figure, plot( f, Pot )
figure, plot( abs(Y) )
Pot = abs(Y(1:NFFT/2)).^2;
figure, plot( f, Pot )
mean( Pot )
std( Pot )
figure, errorbar( f, Pot, std(Pot) )
figure, errorbar( f, Pot, repmat(std(Pot),size(Pot)) )
figure, errorbar( f, Pot, repmat(std(Pot),size(Pot)), '.r' )
hist( Pot, 100 )
figure, semilogy( f, Pot )
hist( Pot, 100 )
