Skip to content
Snippets Groups Projects
Commit 9caa028b authored by marwan's avatar marwan
Browse files

correction of frequency scale

parent cf58e27d
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ function varargout = rrspec(varargin) ...@@ -4,7 +4,7 @@ function varargout = rrspec(varargin)
% spectrum based on a recurrence plot using embedding dimension % spectrum based on a recurrence plot using embedding dimension
% M, embedding delay T, recurrence threshold E, maximal lag % M, embedding delay T, recurrence threshold E, maximal lag
% for tau-recurrence W, and sampling frequency FS. The % for tau-recurrence W, and sampling frequency FS. The
% input arguments are similar to those of the command CRP. % input arguments are similar to those of the command TAUCRP.
% %
% P = RRSPEC(...) returns the tau-recurrence rate spectrum % P = RRSPEC(...) returns the tau-recurrence rate spectrum
% in vector P. % in vector P.
...@@ -14,12 +14,16 @@ function varargout = rrspec(varargin) ...@@ -14,12 +14,16 @@ function varargout = rrspec(varargin)
% %
% Example: fs = 22; % Example: fs = 22;
% x = sin(2*pi * [0:1/fs:44]); % x = sin(2*pi * [0:1/fs:44]);
% rtspec(x,2,1,.1,fs); % rrspec(x,2,1,.1,[],fs)
% %
% See also TAUCRP, RTSPEC. % See also TAUCRP, RTSPEC.
% %
% Copyright (c) 2008 by AMRON % Copyright (c) 2008-2009
% Norbert Marwan, Potsdam Institute for Climate Impact Research, Germany
% http://www.pik-potsdam.de
%
% Copyright (c) 2008
% Norbert Marwan, Potsdam University, Germany % Norbert Marwan, Potsdam University, Germany
% http://www.agnld.uni-potsdam.de % http://www.agnld.uni-potsdam.de
% %
...@@ -27,6 +31,9 @@ function varargout = rrspec(varargin) ...@@ -27,6 +31,9 @@ function varargout = rrspec(varargin)
% $Revision$ % $Revision$
% %
% $Log$ % $Log$
% Revision 5.1 2008/07/02 12:01:13 marwan
% initial import
%
% Revision 5.1 2008/07/01 13:09:27 marwan % Revision 5.1 2008/07/01 13:09:27 marwan
% initial import % initial import
% %
...@@ -42,7 +49,7 @@ w_init = 100; ...@@ -42,7 +49,7 @@ w_init = 100;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% check the input %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% check the input
error(nargchk(1,8,nargin)); error(nargchk(1,8,nargin));
if nargout>1, error('Too many output arguments'), end if nargout>2, error('Too many output arguments'), end
...@@ -136,7 +143,8 @@ fft_RR = fft(tauRR-mean(tauRR)); ...@@ -136,7 +143,8 @@ fft_RR = fft(tauRR-mean(tauRR));
%% spectrum %% spectrum
P = fft_RR .* conj(fft_RR); P = fft_RR .* conj(fft_RR);
%P = fft_RR.^2; %P = fft_RR.^2;
f = fs*linspace(0,.5,length(x)); f = fs*linspace(0,.5,N);
P = P(1:N);
if nargout == 1 if nargout == 1
varargout{1} = P(:); varargout{1} = P(:);
...@@ -145,7 +153,8 @@ elseif nargout == 2 ...@@ -145,7 +153,8 @@ elseif nargout == 2
varargout{2} = f(:); varargout{2} = f(:);
else else
%% Plot the spectrum %% Plot the spectrum
semilogy(f,P(1:length(f))+1) semilogy(f,P(1:N)+1)
grid
xlabel('Frequency'), ylabel('Power') xlabel('Frequency'), ylabel('Power')
title('\tau-Recurrence Rate Spectrum') title('\tau-Recurrence Rate Spectrum')
end end
...@@ -14,12 +14,16 @@ function varargout = rtspec(varargin) ...@@ -14,12 +14,16 @@ function varargout = rtspec(varargin)
% %
% Example: fs = 22; % Example: fs = 22;
% x = sin(2*pi * [0:1/fs:44]); % x = sin(2*pi * [0:1/fs:44]);
% rtspec(x,2,1,.1,fs); % rtspec(x,2,1,.1,fs)
% %
% See also CRP, RRSPEC. % See also CRP, RRSPEC.
% %
% Copyright (c) 2008 by AMRON % Copyright (c) 2008-2009
% Norbert Marwan, Potsdam Institute for Climate Impact Research, Germany
% http://www.pik-potsdam.de
%
% Copyright (c) 2008
% Norbert Marwan, Potsdam University, Germany % Norbert Marwan, Potsdam University, Germany
% http://www.agnld.uni-potsdam.de % http://www.agnld.uni-potsdam.de
% %
...@@ -27,6 +31,9 @@ function varargout = rtspec(varargin) ...@@ -27,6 +31,9 @@ function varargout = rtspec(varargin)
% $Revision$ % $Revision$
% %
% $Log$ % $Log$
% Revision 5.1 2008/07/02 12:01:13 marwan
% initial import
%
% Revision 5.1 2008/07/01 13:09:27 marwan % Revision 5.1 2008/07/01 13:09:27 marwan
% initial import % initial import
% %
...@@ -140,20 +147,22 @@ X = crp2(x,m,t,e,method,norm_str,nogui_str); ...@@ -140,20 +147,22 @@ X = crp2(x,m,t,e,method,norm_str,nogui_str);
%% spectrum %% spectrum
f1 = 0:1/(1000*fs):1; f1 = 0:1/(1000*fs):1;
P1 = histc(1./RT,f1); P1 = histc(1./(RT+1),f1);
P = histc(RT,1:2*max(RT)); P = histc(RT,1:2*max(RT));
f = [1:2*max(RT)]+.5; f = [1:2*max(RT)]+.5;
f2 = fs./(f+1);
if nargout == 1 if nargout == 1
varargout{1} = P(:); varargout{1} = P(:);
elseif nargout == 2 elseif nargout == 2
varargout{1} = P(:); varargout{1} = P(:);
varargout{2} = f(:); varargout{2} = f2(:);
else else
% semilogy(f1*fs,P1+1,fs./f,P+1) semilogy(f1*fs,P1+1,fs./(f+1),P+1)
semilogy(fs./f,P+1) % semilogy(fs./f,P+1)
grid
ylabel('Power') ylabel('Power')
xlabel('Frequency') xlabel('Frequency')
title('Recurrence Time Spectrum') title('Recurrence Time Spectrum')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment