필터 지우기
필터 지우기

conversion of matrix into vector

조회 수: 2 (최근 30일)
krak
krak 2013년 4월 26일
I made an algorithm of conversion of a matrix for a vector of column but it just works for the matrix 3*4. I want that it work on is important dimension(size). All the dimensions(size)! How I make? the code :
x=[1 2 3 0;4 5 6 0;7 8 9 0];
y=x(:,1);
m=2;
while m<5
y=[y;x(:,m)];
m=m+1;
end

채택된 답변

Wayne King
Wayne King 2013년 4월 26일
편집: Wayne King 2013년 4월 26일
Is this important that you write yourself? Because there is a reshape() function
x = randn(10,10);
y = reshape(x,100,1);
If it is important, then just starting from what you have, how about
x = randn(10,10);
y=x(:,1);
m=2;
while m<= size(x,2)
y=[y;x(:,m)];
m=m+1;
end
  댓글 수: 1
krak
krak 2013년 4월 26일
편집: krak 2013년 4월 26일
Thank you for your answer! I have an image (any image) and I want to convert her in a vector of columns! It is the only algorithm which I found! I would like of your help :)

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

추가 답변 (2개)

sammar
sammar 2013년 4월 26일
hey krak try this way if that what you want
x=[1 2 3 0;4 5 6 0;7 8 9 0]; >> B = reshape(x.',1,[]);
  댓글 수: 1
krak
krak 2013년 4월 26일
hey sammar , Yes the function reshape, but how I have to use him under matlab? Thank you for your answer:)

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


Jim
Jim 2013년 4월 26일
Just x(:)

카테고리

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