Reshaping a matrix using a loop or any function inbuilt.

조회 수: 3 (최근 30일)
maharaj
maharaj 2013년 3월 21일
Hello, Does anyone know how to reshape a m*n matrix into m*1*n matrix using loops or any other function. I would definitely appriciate if both the methods are illustrated.

채택된 답변

Jan
Jan 2013년 3월 21일
편집: Jan 2013년 3월 21일
x = rand(3,4);
y = reshape(x, 3, 1, 4);
size(y)
This is such efficient, that it is hard to dare to do this in a loop. Therefore I assume, that the problem is a homework question and to avoid cheating, I ask you to post, what you have done so far to solve it with a loop. Then ask a specific question to the occurring problems.
  댓글 수: 2
maharaj
maharaj 2013년 3월 21일
No its is not a homework problem. It is a code i have been trying to modify to fit into my use.
maharaj
maharaj 2013년 3월 21일
I have a code which computes J matrix which is m*n and now i would want to change it into 3D m*1*n so that I can improve the quality of my image reconxstruction.

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

추가 답변 (1개)

Wouter
Wouter 2013년 3월 21일
a suggestion: permute(matrix,[1 3 2])
this switches dimension 2 and 3 and effectively changes the size of your matrix
  댓글 수: 1
Jan
Jan 2013년 3월 21일
This uses the clearly documented but confusing fact, that in Matlab missing trailing dimensions are assume to be 1 by default.

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

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by