MATLAB: Apply logical matrix to dataset

logical?MATLABmatrix

I have a logical matrix (IdxReturns) with the dimension (589×693) which I would like to apply when calculating the product of my return series (MyReturns). However, when I attempt to apply the logical matrix I get a 9387×1 matrix. How do I go about getting around this? I am using a command that looks like the following:
TempReturn = prod(MyReturns(IdxReturns),2);
Because I am calculating the product function across the rows, I would expect a 589×1 matrix as a result. What am I doing wrong? Do I need to apply the logicals separately?

Best Answer

Thank you guys for your help with this. I actually ended up finding two different solutions that would work. If I apply the logical matrix to the 589x693 matrix I can simply apply a reshape function to get it back to the intended dimensions. Also, if I apply the logical arrays separate from one another rather than creating a logical matrix first, the TempReturns dataset keeps it's form appropriately. I chose this solution and the ending code format can be seen below.
TempReturn = prod(MyReturns(IdxTickers,IdxDates),2)