I am still a newbe and I have probabily a very easy question concerning arrays of matrices. I have a matrix of n
rows like the following one:
>> matrix
1 678 543
2 676 541
3 543 987
4 543 98
1 433 54
2 908 32
3 457 54
4 235 21
How to create arrays of equal size matrices?
i.e array{i,1}
This is replication of question: Array of Matrices in MATLAB and probably of many others.
What is not clear to me, is how to populate my array of fixed dimension matrices. So that
>>array{1,1}
1 678 543
2 676 541
3 543 987
4 543 98
Here is my attempt:
Find all the ones in column 1
of matrix
and the size
of matrix
.
Create cell
arrays, look in each line, if it is equal to 1
create an array{i,1}
of zeros equal to the size of the matrices I want to create (in my case 4x3
).
If not equal to 1
insert into the array the first four values of matrix.
Is there any faster way to do it without a loop?