how to use cell ?

1 回表示 (過去 30 日間)
Mira le
Mira le 2019 年 11 月 25 日
コメント済み: Guillaume 2019 年 11 月 25 日
In my case
>> U
U =
1×2 cell array
[1×2 double] [1×2 double]
>> U{1}
ans =
1 2
>> U{2}
ans =
2 3
F = { } ;
How can I obtain F like that?
F = { {1 2} { 2 3} }

回答 (1 件)

Guillaume
Guillaume 2019 年 11 月 25 日
If you're asking how to transform U into your desired F:
F = cellfun(@num2cell, U, 'UniformOuput', false);
would be one way of doing it.
However, making a cell array of scalar numbers (e.g. {1, 2}) is rarely a good idea. It uses a lot more memory and is more complicated to use.
  4 件のコメント
Mira le
Mira le 2019 年 11 月 25 日
I just forgor to make the right F in the first
Guillaume
Guillaume 2019 年 11 月 25 日
I still have no idea what you're asking since you haven't even explained what we start with and what you're trying to do.

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

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by