reshape a matrix or cell array
    조회 수: 2 (최근 30일)
  
       이전 댓글 표시
    
Hello , I am sorry for repetition i asked this question and deleted it by wrong and want to discuss it again , first my question is when i ave a matrix like this :
 a=[1 
    2 
    3
    4]
and i want to convert it to this form
a=[1 2 
   3 4 
   5 6] 
if i do a reshape  
B=reshape(a,[],2)
B =
     1     3
     2     4
this is a simple example my code have this function to implement it
ENDBR = arrayfun( @(IDX) nonzeros(MY_ARRAY(IDX,:)), 1:size(MY_ARRAY,1), 'Uniform', 0);
thanks
댓글 수: 0
채택된 답변
  Thomas
      
 2012년 3월 29일
        do
    b=reshape(a,[],2)'
to get
b =
     1     2
     3     4
correction will work for more than 2 rows:
a=[1:10]';
  b=reshape(a,2,[])'
  b =
       1     2
       3     4
       5     6
       7     8
     9    10
댓글 수: 2
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
			
	제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

