필터 지우기
필터 지우기

How to make cells consistent in dimensions by shortening

조회 수: 3 (최근 30일)
Thang  Le
Thang Le 2014년 5월 28일
댓글: Star Strider 2014년 5월 28일
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.

채택된 답변

Star Strider
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
  댓글 수: 7
Thang  Le
Thang Le 2014년 5월 28일
Thank you so much, Star Strider!
Star Strider
Star Strider 2014년 5월 28일
My pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by