Placing data in a matrix

조회 수: 2 (최근 30일)
stelios loizidis
stelios loizidis 2020년 12월 30일
댓글: Ameer Hamza 2020년 12월 30일
Hello
I have the following problem: I have a matrix A (12708X1). I want to put the data of matrix A in a matrix B which has size 353X36. In other words, every 36 rows of matrix A become columns for matrix B. I wrote a code but the result is that the resulting matrix B has size 12708X1. How is this problem solved? Your help is important. This is the code I wrote:
% matrix A size:12708X1
B=[];
for i=0:352
B_temp=A(1+(36*i):36+(36*i));
B=[B; B_temp];
end

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 12월 30일
편집: Ameer Hamza 2020년 12월 30일
Directly use reshape()
B = reshape(A, [36 353]).'
  댓글 수: 2
stelios loizidis
stelios loizidis 2020년 12월 30일
It works. Thanks for the quick and valuable response !!!!
Ameer Hamza
Ameer Hamza 2020년 12월 30일
I am glad to be of help!

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

추가 답변 (0개)

카테고리

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