Mostrar comentarios más antiguos
{clear all;close all;
load ch1.dat;load ch2.dat;load ch3.dat;
load ch4.dat;load ch5.dat;load ch7.dat;
channel1=detrend(ch1);
channel2=detrend(ch2);
channel3=detrend(ch3);
channel4=detrend(ch4);
channel5=detrend(ch5);
channel7=detrend(ch7);
disp('Please input the following data')
nfft=input('No. of size Of fft =');
Fs=input('Sampling frequency =');
noverlap=input('noverlap =');
S=input('Channel No.is=');
W=input('Channel No.is=');
S=S(:);
W=W(:);
[Pxy,F] = cpsd(S,W,hann(nfft/2),noverlap,nfft,Fs);
[Pxx,F] = cpsd(S,W,hann(nfft/2),noverlap,nfft,Fs);
[pyy,F] = cpsd(S,W,hann(nfft/2),noverlap,nfft,Fs);
%[Pxy,F] = cpsd(S,W,hann(nfft/2),[],nfft,Fs);
%[Pxx,F] = cpsd(S,W,hann(nfft/2),[],nfft,Fs);
%[pyy,F] = cpsd(S,W,hann(nfft/2),[],nfft,Fs);
%[Pyy,F] = cpsd(W,W,hann(nfft/2),Noverlap,nfft,Fs);
%[Pxy,F] = csd(x,y,nfft,Fs,Window,Noverlap);
A = abs(Pxy);
plot(F,A);
xlabel('Frequency (Hz)'); ylabel('Magnitude');
title('Cross Spectral Density Magnitude');
grid on
figure;
grid on
RR = real( Pxy );
QQ = imag( Pxy );
B = atan2( QQ,RR);
B=B*180/pi;
plot(F,B);
xlabel('Frequency (Hz)'); ylabel('Degree');
title('Cross Spectral Density Phase');
grid on}
This my code.
my ch1.dat and ch2.dat is 528846 column vector
when i added sampling 256Hz fft=2048 overlap =1024
the error msg
??? Error using ==> welchparse at 36 The number of samples to overlap must be less than the length of the segments.
Error in ==> welch at 40 [x,M,isreal_x,y,Ly,win,winName,winParam,noverlap,k,L,options] = ...
Error in ==> cpsd at 101 [varargout{1:nargout}] = welch({x,y},esttype,varargin{:});
Error in ==> channel2fix at 18 [Pxy,F] = cpsd(S,W,hann(nfft/2),noverlap,nfft,Fs);
anyone have idea?
Ted
Respuestas (1)
Sean de Wolski
el 24 de Feb. de 2012
0 votos
put a break point on line 18 and inspect the sizes of the inputs on the line.
Note the error message: The number of samples to overlap must be less than the length of the segments.
It should be obvious at this time.
1 comentario
Ted oscar
el 24 de Feb. de 2012
Categorías
Más información sobre Spectral Measurements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!