How can I set column of matrix divisible by 12

조회 수: 1 (최근 30일)
Farshid Daryabor
Farshid Daryabor 2020년 3월 10일
댓글: Farshid Daryabor 2020년 3월 10일
I have a matrix 'M(1715*3849)' I want to reshape it to a Matrix that the size of the column can divisible with 12. How can I do it?
Thanks in advance.
>> 3849/12
ans =
320.7500
  댓글 수: 2
Turlough Hughes
Turlough Hughes 2020년 3월 10일
Why do you want to do that, can you provide some context? There is no way to do it without removing values or adding empty values.
Farshid Daryabor
Farshid Daryabor 2020년 3월 10일
Yes, adding empty values.

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

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 3월 10일
편집: Ameer Hamza 2020년 3월 10일
It will append columns with nan value
M = rand(1715, 3849);
extra_columns = ceil(size(M,2)/12)*12 - size(M,2);
M = padarray(M, [0, extra_columns], nan, 'post');
size(M,2)/12
Result:
ans =
321

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