0
votes

In MATLAB, I want to declare a 4D matrix, where the last dimension can take two values (a 2-column vector is the last dimension). The trouble is, zeros(...) only accepts scalars, so I can't declare the vector within the matrix declaration. Any thoughts on how to do this?

i.e. in the below, how do I declare this array so that 'output' actually looks like output=zeros(some_number,2);

beg=zeros(nsubj,nvids,nmark,output);
1
You want a 5D matrix not a 4D matrix. I give up after 3D!IKavanagh
Okay, I see. Thank you!skirmishdirmish

1 Answers

0
votes

In order to have the last dimension contain a 2-column vector, you need to define the 2 columns in the second dimension of your declaration like so:

>> beg = zeros(4, 2, b, c);

Here is the first 2-column vector of the last dimension:

>> beg(:,:,1,1)  

ans =

 0     0
 0     0
 0     0
 0     0

I hope this helps!