NT2FR Calculates the frequency matrix given the counting distribution matrix. CALL: fr = nt2fr(NT); fr = nt2fr(NT,def); where fr = the frequency matrix, NT = the counting distribution matrix, def = 0,1 k = number of diagonals from main diagonal to be set to zero (optional input argument). If def=0 function computes the inverse to N_T(u,v) = #{ (M_i,m_i); M_i>u, m_i<v } and if def=1 the inverse to N_T(u,v) = #{ (M_i,m_i); M_i>=u, m_i=<v } where (M_i,m_i) are cycles and v,u are in the discretization grid.
001 function F=nt2fr(M,def) 002 %NT2FR Calculates the frequency matrix given the counting distribution matrix. 003 % 004 % CALL: fr = nt2fr(NT); 005 % fr = nt2fr(NT,def); 006 % 007 % where 008 % 009 % fr = the frequency matrix, 010 % NT = the counting distribution matrix, 011 % def = 0,1 012 % k = number of diagonals from main diagonal to be 013 % set to zero (optional input argument). 014 % 015 % If def=0 function computes the inverse to 016 % 017 % N_T(u,v) = #{ (M_i,m_i); M_i>u, m_i<v } 018 % 019 % and if def=1 the inverse to 020 % 021 % N_T(u,v) = #{ (M_i,m_i); M_i>=u, m_i=<v } 022 % 023 % where (M_i,m_i) are cycles and v,u are in the discretization grid. 024 % 025 026 027 n=length(M); P=zeros(size(M)); 028 029 if nargin<2 030 def=0; 031 end 032 033 if def==0 034 P(1:n-1,1:n-1)=M(1:n-1,1:n-1)+M(2:n,2:n)-M(1:n-1,2:n)-M(2:n,1:n-1); 035 else 036 P(2:n,2:n)=M(1:n-1,1:n-1)+M(2:n,2:n)-M(1:n-1,2:n)-M(2:n,1:n-1); 037 end 038 039 %if nargin==2 040 % k_cut=k; 041 %else 042 % k_cut=2; 043 %end 044 045 F=P; 046 047 %F=fliplr(triu(fliplr(P),k_cut)); 048 049 050
Comments or corrections to the WAFO group