Error: Subscripting a table using linear indexing (one subscript) or multidimensional indexing (three or more subscripts) is not supported

185 views (last 30 days)
Ameer Fahmi
Ameer Fahmi on 24 Oct 2019
Commented: Ameer Fahmi on 24 Oct 2019
I have two weekly time series y1 and y1 with 1199 observations, and I want to estimate the correlation between between the two series using semblance analysis form this program, I used the command below to run the program
where t is dates, y1 and y2 are my variables and 100 is number of scales
This is the code of the program
function s=semblance(t,y1,y2,nscales)
% SEMBLANCE(t,y1,y2,nscales)
% Produces a cross-correlation plot between two timeseries as a function of
% both time and wavelength
% *** Requires Matlab wavelet toolbox
% Type semblance; for demo with synthetic data
% Inputs;
% t Time axis
% y1,y2 Datasets to be compared
% nscales No. of scales/wavelengths to use - not more than length(t)...
% Outputs;
% s : Semblance; a matrix of values between -1 (anticorrelated),
% zero (uncorrelated), and +1 correlated
% *******************************************************
% *** Wavelet-Based semblance analysis
% *** GRJ Cooper 2005
% *** School of Geosciences, University of the Witwatersrand
% *** Johannesburg, South Africa
% ***,
% ***
% *******************************************************
% If you use this program please reference this paper;
% Cooper, G.R.J., and Cowan, D.R., 2008.
% Comparing Time Series using Wavelet Based Semblance Analysis
% Computers & Geosciences v.34(2) p.95-102.
% E-mail me for the pdf if you're interested
% ******************************************************
if nargin==0; % demo analysis
y1(isnan(y1))=0; y2(isnan(y2))=0;
m1=mean(y1(:)); m2=mean(y2(:)); y1=y1-m1; y2=y2-m2;
ctc=c1.*conj(c2); % Cross wavelet transform amplitude
s=cos(spt); % Semblance
% Display results
figure(1); clf;
currfig=get(0,'CurrentFigure'); set(currfig,'numbertitle','off');
set(currfig,'name','Wavelet Semblance Analysis');
y1=y1+m1; y2=y2+m2;
subplot(5,1,1); plot(t,y1); axis tight; title('Data 1');
subplot(5,1,2); imagesc(real(c1)); axis xy; axis tight; title('CWT'); ylabel('Wavelength');
subplot(5,1,3); plot(t,y2); axis tight; title('Data 2');
subplot(5,1,4); imagesc(real(c2)); axis xy; axis tight; title('CWT'); ylabel('Wavelength');
subplot(5,1,5); imagesc(s,[-1 1]); axis xy; axis tight; title('Semblance'); ylabel('Wavelength');
First I got this error
Undefined function 'isnan' for input arguments of type 'table'.
Error in semblance (line 41)
y1(isnan(y1))=0; y2(isnan(y2))=0;
However, this function is for detecting the NaN values in the arrays, and since there are no NaNs in my data, I removed this line from the code, then I ran it again
I got another error and I couldn't solve it
Error using semblance (line 42)
Subscripting a table using linear indexing (one subscript) or multidimensional indexing (three or more
subscripts) is not supported. Use a row subscript and a variable subscript.
No metter what I do, I keep getting this error,

Accepted Answer

Matt J
Matt J on 24 Oct 2019
Convert your y1 and y2 to arrays before doing anything else:
function s=semblance(t,y1,y2,nscales)
if istable(y1), y1=table2array(y1); end
if istable(y2), y2=table2array(y2); end

More Answers (0)




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!