I have 72 x 1 cell named let's say output1, each cell got 8 x 1 entries. Now, I intend to store each 8 x 1 entries into the seperate array, such that finally I will get 8 x 72 array.
I used cell2mat(output1) Instead of 8 x 72 array, it stores all entries in the single column i.e. i got 576 x 1 , please let me know how to get this ..

 採用された回答

Stephen23
Stephen23 2021 年 7 月 16 日
編集済み: Stephen23 2021 年 7 月 16 日

0 投票

The robust approach:
out = horzcat(output1{:})

3 件のコメント

Turbulence Analysis
Turbulence Analysis 2021 年 7 月 16 日
Hi Stephen,
Tried the same, got the below error msg.
Attached here the output1 cell for your reference
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
Stephen23
Stephen23 2021 年 7 月 16 日
編集済み: Stephen23 2021 年 7 月 16 日
Almost all of the cells contain column vectors of eight elements, but a few of them have five/six elements:
>> S = load('matlab.mat')
S =
output1: {72x1 cell}
>> nmr = cellfun('size',S.output1,1);
>> unique(nmr)
ans =
5
6
8
>> hist(nmr,unique(nmr))
It is not possible to horizontally concatenate column vectors with different numbers of elements. You will have to fix your data, or use a tool that pads the vectors automatically for you, e.g.:
"...each cell got 8 x 1 entries..."
is what you wrote in your question, but this statement does not match the data you uploaded.
Turbulence Analysis
Turbulence Analysis 2021 年 7 月 16 日
Thanks a lot for directing to the link.. It did the job perfectly..

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

その他の回答 (1 件)

Akshit Bagde
Akshit Bagde 2021 年 7 月 16 日

0 投票

Convert the cell array to a row vector, and then try. It should work
cell2mat(output1')

カテゴリ

ヘルプ センター および File Exchange で Data Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by