Placing data in a matrix

3 Ansichten (letzte 30 Tage)
stelios loizidis
stelios loizidis am 30 Dez. 2020
Kommentiert: Ameer Hamza am 30 Dez. 2020
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

Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 30 Dez. 2020
Bearbeitet: Ameer Hamza am 30 Dez. 2020
Directly use reshape()
B = reshape(A, [36 353]).'
  2 Kommentare
stelios loizidis
stelios loizidis am 30 Dez. 2020
It works. Thanks for the quick and valuable response !!!!
Ameer Hamza
Ameer Hamza am 30 Dez. 2020
I am glad to be of help!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by