필터 지우기
필터 지우기

Matrix Conversion

조회 수: 2 (최근 30일)
rahman
rahman 2011년 4월 18일
Hi all
I have a 1-by-N^4 matrix that I want to convert in to N^2-by-N^2 matrix(for example:a=[1 2 3 4] to b=[1 2;3 4]). I use this code:
for ii=1:N^2
b(ii,1:N^2)=a((ii-1)*(N^2)+1:ii*(N^2));
end
But for larg N this is very time consuming.
1-Is there any command do that?
2-How can I set the index for using PARFOR loop?

채택된 답변

Oleg Komarov
Oleg Komarov 2011년 4월 18일
use reshape:
a = [1 2 3 4];
reshape(a,2,2).'
You may find also useful Resizing and Reshaping Matrices
  댓글 수: 1
rahman
rahman 2011년 4월 18일
Tnx lot

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by