필터 지우기
필터 지우기

how to format vector as matrix?

조회 수: 1 (최근 30일)
Berbia
Berbia 2012년 12월 1일
I have a long row vector say,v=[1 2 3 ... 100]. I'm in need to convert it into a matrix m=[1 2 3 4 5;6 7 8 9 10; ..... ;96 97 98 99 100] i.e),for each row 5 elements...Is it possible in matlab? if so how???

채택된 답변

Walter Roberson
Walter Roberson 2012년 12월 1일
m = reshape(v, 5, []) .' ;
Notice this first creates columns of 5 and then transposes so they become rows, rather than creating rows of 5 directly. This has to do with the order that reshape() takes elements to be reshaped.

추가 답변 (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