How to divide matrix into sub matrix
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Isai Noyola
am 4 Feb. 2018
Beantwortet: Star Strider
am 4 Feb. 2018
I have the matrix: time=0:0.05:8; and I'm trying to divide it into multiple matrices of 4. I tried using:
TIME=mat2cell(time,1,4) but i don't know what I'm doing wrong.
1 Kommentar
Greg
am 4 Feb. 2018
Can you elaborate? I'm not following "multiple matrices of 4." What are you wanting to do with the sub-matrices?
Akzeptierte Antwort
Star Strider
am 4 Feb. 2018
First, this is easier if you create ‘time’ so the length is an integer multiple of 4.
Then, creating the cell array is straightforward:
time=0:0.05:8-0.05;
TIME=mat2cell(time,1, fix(numel(time)/4)*ones(1,4))
This creates ‘TIME’ as 4 (1x40) cell arrays, because ‘fix(numel(time)/4)’ for this ‘time’ vector is 40.
The row and column dimensions of the arguments to mat2cell must equal the row and column dimensions of the argument array.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!