How to make cells consistent in dimensions by shortening
    5 次查看(过去 30 天)
  
       显示 更早的评论
    
Hi,
I have cell array P which contains something like this:
< 15x1 double > < 14x1 double > < 16x1 double > < 14x1 double >...
I'd like to concatenate all these into a single cell so I did the following:
Summary.D ={cell2mat(P)};
However, I got an error due to the inconsistent dimensions of different cells above. Since the number of rows in those cell range from 14 to 16, I could just reduce all the 14x1. However, I'm not sure how to shorten these cells. Could anyone help?
Thanks.
0 个评论
采纳的回答
  Star Strider
      
      
 2014-5-28
        This works:
P = {cell(14,1) cell(16,1)}
P{1} = rand(14,1)
P{2} = rand(16,1)
Q = [];
for k1 = 1:size(P,2)
    Q = [Q; cell2mat(P(k1))];
end
Q                   % Display result
更多回答(0 个)
另请参阅
类别
				在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
			
	产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!