How to make indices integers/logicals while filling 3D matrix with data?
Show older comments
Hello,
I got error: 'Subscript indices must either be real positive integers or logicals.'
While filling 3D matrix using triple loop:
function [m3d] = matrixfill(ROIs, dm)
%Filling 3D matrix with phase difference values for ROIs pairs and saving
%to .mat file.
ROIs_length = length(ROIs);
time_length=size(dm,1); %to define time we need to know length of time series
times=0:1.83:((time_length-1)*1.83); %time defined
for d=1:ROIs_length
x=[times; dm(:,ROIs(d))'];
for e=1:ROIs_length
y=[times; dm(:,ROIs(e))'];
[Rsq,period,scale,coi,sig95,X,Y,Wxy,sWxy,ejpdXY]=wtc_AA(x,y,'MonteCarloCount',1);
period_length=length(period);
for f = 1:period_length
freq=period(f);
m3d = zeros(period_length,ROIs_length,time_length); %3D matrix filled with zeros
m3d(d,x,f) = mean(angle(Wxy(freq,:)));
%error: Subscript indices must either be real positive integers or logicals.
%filling matrix with means of phase difference
end
end
filename=sprintf('for_ROI%d.mat',d);
save(filename);
end
end
How to fix it?
Thanks in advance.
Kasia
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!