Convert a 3-d matrix to a 2-d matrix
Mostrar comentarios más antiguos
I have this variable 'a'. I want to convert it into a 2-d matrix of dimensions 3*3. The output I am looking for is a 3*3 matrix denoted by 'b'. Any help will be appreciated.
a=randi(10,3,3,2)
val(:,:,1) =
1 3 8
6 4 8
3 1 6
val(:,:,2) =
4 10 6
9 9 4
6 4 7
b =
14 310 86
69 49 84
36 14 67
Respuesta aceptada
Más respuestas (2)
Jan
el 23 de Ag. de 2013
b = zeros( size(a, 1), size(a, 2) );
for i = 1 : size(a, 3);
b = b + 10.^(size(a, 3) - i) * a(:,:,i);
end;
Azzi Abdelmalek
el 23 de Ag. de 2013
Editada: Azzi Abdelmalek
el 23 de Ag. de 2013
out=val(:,:,1).*10.^(fix(val(:,:,2)/10)+1)+val(:,:,2)
1 comentario
Vishal
el 23 de Ag. de 2013
Categorías
Más información sobre Linear Algebra en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!