Extracting only some cell arrays from a cell- based on a double array

1 ビュー (過去 30 日間)
BN
BN 2022 年 7 月 19 日
編集済み: Jonas 2022 年 7 月 19 日
Dear all,
I have a 1*29 cell (C) containing tables. For example C{1,1} = 444*12 table.
From this 1*29 cell, I want to keep only selected arrays based on the a=[ 1 3 15 19 20 29] variable.
I want to have a final cell like the below:
NewC = {C{1, 1}, C{1,3}, C{1,15}, C{1,19}, C{1,20}, C{1,29}}
Since the real dataset is bigger, I want to know if there is any way to do this using cellfun or a loop.
Best regards.

採用された回答

Jonas
Jonas 2022 年 7 月 19 日
編集済み: Jonas 2022 年 7 月 19 日
something like this:
yourCell=cellstr(num2str((1:29)'))'
yourCell = 1×29 cell array
{' 1'} {' 2'} {' 3'} {' 4'} {' 5'} {' 6'} {' 7'} {' 8'} {' 9'} {'10'} {'11'} {'12'} {'13'} {'14'} {'15'} {'16'} {'17'} {'18'} {'19'} {'20'} {'21'} {'22'} {'23'} {'24'} {'25'} {'26'} {'27'} {'28'} {'29'}
someOfThemIdx=[ 1 3 15 19 20 29];
someOfThem=yourCell(someOfThemIdx)
someOfThem = 1×6 cell array
{' 1'} {' 3'} {'15'} {'19'} {'20'} {'29'}

その他の回答 (0 件)

カテゴリ

Find more on Tables in Help Center and File Exchange

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by