フィルターのクリア

how to convert the cell to matrix

2 ビュー (過去 30 日間)
Shehab Tarek
Shehab Tarek 2020 年 5 月 15 日
編集済み: Stephen23 2020 年 5 月 16 日
i have cell as shown in picture
and i want to convert it to Array then flip it to be like
array=
00
10
010
110
111
EDIT: Shehab Tarek's "Answer" moved here:
%YY
%[0,0]
%[0,1]
%[0,1,0]
%[1,1,0]
%[0,1,1]
%[1,1,1]
matrix=[];
lenght=[];
for i=1:6
[~,c]=size(YY{i}); % the cell matrix
length=[length c]; % length of each element in cell
s=YY{i}; % variable
matrix=[matrix s];
end
length=length';
although you can show the code in file un.m
  3 件のコメント
Shehab Tarek
Shehab Tarek 2020 年 5 月 15 日
i know that the vector lenght is not the same .then i have the length of each array in the cell for example
length=[2,2,3,3,3];
martix=0010010010110111;
i want to diveded the matrix to sub element depend on the length
to be
matrix =[00,10,010,110,111];
Ameer Hamza
Ameer Hamza 2020 年 5 月 15 日
Can you share the code which is used to generate the matrix? You cannot represent 0010010010110111 in floating-point format. Is it a character array?

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

回答 (1 件)

dpb
dpb 2020 年 5 月 16 日
Presuming the input is a cell array, m...
>> cellfun(@(s) sprintf('%d',fliplr(s)),m,'UniformOutput',false)
ans =
6×1 cell array
{'00' }
{'01' }
{'010'}
{'011'}
{'110'}
{'111'}
>>
NB: the sample output has only five elements of the six in the input array...

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by