Extract data from cell array

조회 수: 20 (최근 30일)
Christian Schäfer
Christian Schäfer 2021년 9월 8일
답변: Star Strider 2021년 9월 8일
Dear all,
I'm struggling a bit with extracting the data from a cell array B so that I can continue working with it. It is of type 10x1 cell where each cell contains two dimensional line profile data (2047x2 double). The idea is to extract every profile line out of B and calculate different surface roughness parameters. My question now is:
Currently I'm extracting the data with:
L1 = B{1,1}
L2 = B{2,1}
etc.
The function cell2table doesn't really work in my case, since the output of it is a 10x1 table. Is there an easier solution to extract the data? Maybe with a for loop?
Thanks a lot for helping
Christian

답변 (1개)

Star Strider
Star Strider 2021년 9월 8일
Perhaps cell2mat would work. or alternatively, adding square brackets to concatenate the cell contents:
L1 = [B{1,1}]
L2 = [B{2,1}]
Assigning the cells to individual variables (numbered or not) is not considered to be good programming practice in any event, so please avoid that if at all possible. Keep the elements of ‘B’ in an array of some description, and refer to the elements of the array instead.
.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by