how to format cell array
2 次查看(过去 30 天)
显示 更早的评论
so my code outputs a 1x36 cell array in the workspace when executed, i need to reformat the cell array so that once you double click the 1x36 cell array all the values are 1x1 cells. so for instance i click on the 1x36 cell array and if i need the 4th column value i go to the fourth column and double click the 1x1 cell and then the value appears.
3 个评论
Adam Danz
2018-7-1
I'm not sure I understand complete so correct me if I'm wrong. You currently have a cell array like this
a = {1 2 3 4 5 6};
but you want this
a = {{1} {2} {3} {4} {5} {6}};
Is that right?
dpb
2018-7-1
编辑:dpb
2018-7-1
Why not just use a regular 1D vector array and have all the values directly?
a=cell2mat(c);
No clickee needed... :)
Cell arrays are fine when one has either disparate data types or "jagged" arrays or the like, but when "regular" array will suffice it's generally much simpler to code and less memory and faster to boot...
But, iff'en you're determined, I think what you're asking for is
c=num2cell(c{:});
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!