Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You <strong>cannot</strong> remove different rows from a 3D array, you can remove 'floors', or layers or 'walls'. (If you imagine a building by layer I intend a vertical and perpendicular plane to your point of vision while a wall is a vertical plane along your point of vision).</p> <p>You <strong>should not</strong> store numeric data in this way, i.e. one number per cell. You incur in a 112 bytes <strong>overhead</strong> per cell when a scalar double is only 8 bytes. </p> <p>According to the sparsity pattern I can observe from your example, you might benefit by converting it into a <strong>sparse</strong> array which still reference against the original size of the array but without storing <code>0</code> or <code>[]</code>. However, sparse arrays are only 2D, where the additional layers (from a 3rd dimension) are stored consecutively along the 2nd dimension. </p> <p>A simplified version of your example will clarify:</p> <pre><code>val(:,:,1) = { [20] [] [] [] [ 0] [] [] [] [ 0] [] [] [] [] [] [] []}; val(:,:,2) = { [ 34225] [ 215] [ 0] [ 0] [ 85200] [ 545] [ 0] [ 0] [ 65074] [ 190] [ 1000] [ 0] [] [] [] [] }; % Find non-zero empty elements (0s will be discarded automatically) [r,c] = find(~cellfun('isempty',val)); % Convert to sparse (note the coordinates are only 2D) sp = sparse(r,c,[val{:}]); sp = (1,1) 20 (1,5) 34225 (2,5) 85200 (3,5) 65074 (1,6) 215 (2,6) 545 (3,6) 190 (3,7) 1000 % Convert to full to see what happened with the 3rd dimension full(sp) ans = 20 0 0 0 34225 215 0 0 0 0 0 0 65074 190 0 0 0 0 0 0 85200 545 1000 0 </code></pre> <p>you can see that the second layer has been concatenated horizontally (along columns). You can use reshape if you need to recover the 3D.</p> <p>The advantage of <code>val</code> vs <code>sp</code> is in the reduced storage:</p> <pre><code> Name Size Bytes Class Attributes sp 3x8 200 double sparse val 4x4x2 3704 cell </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload