필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Use of max iteratively on a cell

조회 수: 2 (최근 30일)
Isma_gp
Isma_gp 2016년 9월 28일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi, I have a 1x4cell (seekeddata_s) with 4 8x7 cells like the attached one (sl_ts). All of them 8x7 but each of them could have a different size of the singles inside. I would like to get 4 8x7 cells with the maximum value from each cell and store the results on a structure.
I have tried the structure like this, but the max function is not working properly:
if true
% code
end
%%%%%%%%%%%%%%%%%%%%%%%%%
sl_data = [] ;
%
% for every file
for ii = 1:4
file_data = seekeddata_s{1,ii} ;
t = C_t{1,ii};
for jj = 1:8
for kk =1: 7
sl_ts = file_data (:,:);
[mo,to] = max(sl_ts{jj,kk}) ;
sl_data = setfield(sl_data,['file_' num2str(ii)],'max_sl',{jj,kk},mo);
sl_data = setfield(sl_data,['file_' num2str(ii)],'sl_ts',{':',':'},sl_ts);
sl_data = setfield(sl_data,['file_' num2str(ii)],'time_ts',{1,':'},t);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  댓글 수: 4
KSSV
KSSV 2016년 9월 28일
Each cell has a column vector....
Isma_gp
Isma_gp 2016년 9월 28일
I'm trying to store the resulting cells with the maximums on the structure above, where I also store other data.

답변 (1개)

Thorsten
Thorsten 2016년 9월 28일
편집: Thorsten 2016년 9월 28일
I think that a main problem is who to compute the max values.
You can compute the max of each cell as follows:
M = cellfun(@(c) double(max(c)), slamming_ts, 'Uni', false);
Find the empty cells and replace with NaN
E = cell2mat(cellfun(@isempty, M, 'Uni', false));
M(E) = {NaN};
Convert 8 x 7 cell to 8 x 7 matrix:
M = cell2mat(M);

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by