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)
% spectrum based on a recurrence plot using embedding dimension
% M, embedding delay T, recurrence threshold E, maximal lag
% 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
% in vector P.
......@@ -14,12 +14,16 @@ function varargout = rrspec(varargin)
%
% Example: fs = 22;
% x = sin(2*pi * [0:1/fs:44]);
% rtspec(x,2,1,.1,fs);
% rrspec(x,2,1,.1,[],fs)
%
% 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
% http://www.agnld.uni-potsdam.de
%
......@@ -27,6 +31,9 @@ function varargout = rrspec(varargin)
% $Revision$
%
% $Log$
% Revision 5.1 2008/07/02 12:01:13 marwan
% initial import
%
% Revision 5.1 2008/07/01 13:09:27 marwan
% initial import
%
......@@ -42,7 +49,7 @@ w_init = 100;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% check the input
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));
%% spectrum
P = fft_RR .* conj(fft_RR);
%P = fft_RR.^2;
f = fs*linspace(0,.5,length(x));
f = fs*linspace(0,.5,N);
P = P(1:N);
if nargout == 1
varargout{1} = P(:);
......@@ -145,7 +153,8 @@ elseif nargout == 2
varargout{2} = f(:);
else
%% Plot the spectrum
semilogy(f,P(1:length(f))+1)
semilogy(f,P(1:N)+1)
grid
xlabel('Frequency'), ylabel('Power')
title('\tau-Recurrence Rate Spectrum')
end
......@@ -14,12 +14,16 @@ function varargout = rtspec(varargin)
%
% Example: fs = 22;
% x = sin(2*pi * [0:1/fs:44]);
% rtspec(x,2,1,.1,fs);
% rtspec(x,2,1,.1,fs)
%
% 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
% http://www.agnld.uni-potsdam.de
%
......@@ -27,6 +31,9 @@ function varargout = rtspec(varargin)
% $Revision$
%
% $Log$
% Revision 5.1 2008/07/02 12:01:13 marwan
% initial import
%
% Revision 5.1 2008/07/01 13:09:27 marwan
% initial import
%
......@@ -140,20 +147,22 @@ X = crp2(x,m,t,e,method,norm_str,nogui_str);
%% spectrum
f1 = 0:1/(1000*fs):1;
P1 = histc(1./RT,f1);
P1 = histc(1./(RT+1),f1);
P = histc(RT,1:2*max(RT));
f = [1:2*max(RT)]+.5;
f2 = fs./(f+1);
if nargout == 1
varargout{1} = P(:);
elseif nargout == 2
varargout{1} = P(:);
varargout{2} = f(:);
varargout{2} = f2(:);
else
% semilogy(f1*fs,P1+1,fs./f,P+1)
semilogy(fs./f,P+1)
semilogy(f1*fs,P1+1,fs./(f+1),P+1)
% semilogy(fs./f,P+1)
grid
ylabel('Power')
xlabel('Frequency')
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