Effacer les filtres
Effacer les filtres

Matrix Conversion

2 vues (au cours des 30 derniers jours)
rahman
rahman le 18 Avr 2011
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?

Réponse acceptée

Oleg Komarov
Oleg Komarov le 18 Avr 2011
use reshape:
a = [1 2 3 4];
reshape(a,2,2).'
You may find also useful Resizing and Reshaping Matrices
  1 commentaire
rahman
rahman le 18 Avr 2011
Tnx lot

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by