extracting numbers from a cell

1 回表示 (過去 30 日間)
asim nadeem
asim nadeem 2018 年 8 月 19 日
コメント済み: asim nadeem 2018 年 8 月 20 日
SP={{{1,4,5,6},{2},{3}}}
SP =
1×1 cell array
{1×3 cell}
d=SP{1}
d =
1×3 cell array
{1×4 cell} {1×1 cell} {1×1 cell}
d{1}
ans =
1×4 cell array
{[1]} {[4]} {[5]} {[6]}
I want d{1} to be
1 4 5 6
to be able to use these as indices of a matrix.

採用された回答

Paolo
Paolo 2018 年 8 月 19 日
d = SP{:}
>>[d{1}{:}]
1 4 5 6
  1 件のコメント
asim nadeem
asim nadeem 2018 年 8 月 20 日
I used cell2matrix.Thanks

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2018 年 8 月 19 日
編集済み: Image Analyst 2018 年 8 月 19 日
This will do it
SP={{{1,4,5,6},{2},{3}}}
d=SP{1}
d{1} = [d{1}{:}]
but that is a really crazy number storage and I don't recommend it at all. You have a single cell SP with another single cell in side of it. Then inside that cell is a 3-by-1 cell array. Then each of the 3 cells in the interior cell array is also a cell, instead of just a regular number. Could you possibly make it any more complicated?
First of all, you should read the FAQ to learn how to use cell arrays: click here
Then you should set it up like this:
SP={[1,4,5,6], [2], [3]}
Then you can say
d1 = SP{1}
d2 = SP{2}
d3 = SP{3}
if you want separate arrays with contents of each cell of SP for convenience in referring to them
  1 件のコメント
asim nadeem
asim nadeem 2018 年 8 月 20 日
Thanks

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by