How can I change from Cell to Double and writing in many lines
1 次查看(过去 30 天)
显示 更早的评论
Dear, I would like solve a problem about transformation and save in the file
I have a file A that is 19x1 cell. And in each cell I have a matrix 6x6. for example A(1,1) = 6x6 Double, A(2,1) = 6x6 Double ...A(19,1) = 6x6 Double.
I would like write the file A in Double and each matrix stay in one line with 36 column and write (save) these data in the archive.
For example:
From A(1,1) = 6x6 Double to A(1,36)
From A(2,1) = 6x6 Double to A(2,36)
From A(3,1) = 6x6 Double to A(3,36)
.
.
From A(19,1) = 6x6 Double to A(19,36)
0 个评论
采纳的回答
Rik
2019-4-5
The code below should do what you want.
%generate input
A=cellfun(@(x) {x+rand(6,6)},num2cell(1:19)');
%convert the cell contents to row vectors
B=cellfun(@(x) reshape(x,1,[]),A,'UniformOutput',false);
%concatenate into a single double array
C=cell2mat(B);
4 个评论
Rik
2019-4-6
Rewrite the anonymous function inside the cellfun to suit your needs.
Also, if my answer solved your problem, please consider marking it as accepted answer.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!