splitting up numbers in a cell of a double
8 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I have a 22x1 double array with numbers such as 0100001 0100100 in each cell. How would i split this up into a 154x1 (22*7) vector with
0
1
0
0
0
0
1
0
1
0
0
1
0
0
etc
0 件のコメント
回答 (2 件)
Star Strider
2020 年 10 月 13 日
編集済み: Star Strider
2020 年 10 月 13 日
EDIT — (13 Oct 2020 at 12:53)
(Question was essentially completely changed.)
To clarify, it is not a double array, because the leading zeros would not be present. Most likely is’s a cell array:
v = {'0100001' '0100100'};
and it’s relatively straightforward (although not at all obvious) to get the result you want:
Out = reshape([v{:}]-'0', [],1)
producing:
Out =
0
1
0
0
0
0
1
0
1
0
0
1
0
0
.
4 件のコメント
Star Strider
2020 年 10 月 13 日
編集済み: Star Strider
2020 年 10 月 13 日
Brace indexing would not work for a double array, only a cell array.
Something is not correct, since a double would not have leading zeros.
It would help to see the actual original data, most likely as a .mat file.
(13:12 UCT) With respect to your edited Comment, I am now thoroughly lost. I have no idea what your data actually are, much less how to deal with what appears to be a moving target.
madhan ravi
2020 年 10 月 13 日
編集済み: madhan ravi
2020 年 10 月 13 日
Wanted = vertcat(cell_array{:})
%or
Wanted = cat(1, cell_array{:})
2 件のコメント
madhan ravi
2020 年 10 月 13 日
編集済み: madhan ravi
2020 年 10 月 13 日
cell_array = {[0,1,0,0,0,0,1].', [0,1,0,0,1,0,0].'};
Wanted = vertcat(cell_array{:})
%or
Wanted = cat(1, cell_array{:})
参考
カテゴリ
Help Center および File Exchange で Whos についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!