Loop in a cell array that consist of matrices in each cell

조회 수: 1 (최근 30일)
Anirudh Peralai Ravisundar
Anirudh Peralai Ravisundar 2021년 9월 23일
댓글: Anirudh Peralai Ravisundar 2021년 9월 23일
I have written a loop to extract data from a 24x1 cell array, where each cell is of 36000x16 double table. I want to find the maximum value of column 12 in each of the 24 cells and store them in a matrix. But I'm getting an error 'Array indices must be positive integers or logical values.'
%% Loop for extracting data from a cell array
% results is a 24x1 cell array. Each cell consist of 36000x16 double table
for k =1:numel(results)
t = results{k,:}; % extracting every matrix within a cell
% values of interest is in column 12
temp = t(2:end, 12:12);
% find maximum value
max_column = max(temp);
end

답변 (2개)

Matt J
Matt J 2021년 9월 23일
편집: Matt J 2021년 9월 23일
You have a variable called "max" previously defined in your workspace.

Matt J
Matt J 2021년 9월 23일
편집: Matt J 2021년 9월 23일
Easier:
results=cat(3,results{:});
max_column = squeeze( max(results(2:end,12,:)) )

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by