How to populate a cell array from another cell array?
조회 수: 12 (최근 30일)
이전 댓글 표시
I want to populate a cell array called "labels". "Labels" should contain 4 labels for each measurement, so If I'm not wrong the cell array will be 1x4
The cell array where the info is from is called "m_test" which is a 23x117 cell. In order to populate "labels" is just needed the first row and take the first 4 data (starting at the second column), then the other 4 and so on
Some of you have any idea in how to do that?
Thank you so much
댓글 수: 0
채택된 답변
James Tursa
2021년 3월 8일
It is not clear what elements you need extracted. But you can use regular indexing with cell arrays. E.g.,
result = m_test(1,2:5)
would pick off the elements in the first row and columns 2 through 5. Etc.
댓글 수: 2
James Tursa
2021년 3월 10일
for k=2:4:size(m_test,2)
result = m_test(1,k:k+3);
% code that uses result goes here
end
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!