Thanks for your reply, Rik and Adam!
Accessing cell array contents
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a one-dimensional cell array where each element of the array contains a timetable with identical format. Is there a direct way of creating a vector that contains the last element of one specific variable in each timetable (without looping)?
For example, something like:
CellArray{:}.Variable(end)
댓글 수: 2
Rik
2022년 6월 30일
You're welcome. If either answer solved your problem, feel free to mark it as accepted answer. If the other was helpful as well, consider giving it an upvote.
채택된 답변
Rik
2022년 6월 30일
편집: Rik
2022년 6월 30일
No. You could use cellfun, but that will only hide the loop. Using a loop directly tends to have better efficiency.
But don't worry: loops are not as bad as you might think (especially if you pre-allocate the output). They are only bad when there isn't a builtin equivalent that operates on the entire array.
댓글 수: 1
참고 항목
카테고리
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!