Is there a way to dynamically crop N-dimensional data into an N-1 set? I have no knowledge of N before runtime, nor of the dimension on which to crop.
I need to write a 'trimming' function of the form:
>> data_NDm1 = one_dim_trim(ndata, 1, x);
% which will allow me to replace any of the
>> data_NDm1 = data_ND(x,:);
>> data_NDm1 = data_ND(x,:,...,:);
% or replace
>> data_NDm1 = ndata(:,x,:,...,:);% with
>> data_NDm1 = one_dim_trim(ndata, 2, x);
I have already written a 'cropping' function like
>> data_1D = one_dim_crop(ndata, [3, NaN, 4, 7]);
% which takes variable size arguments and replaces:
>> data_1D = ndata(3, :, 4, 7);
...but I'm kind of stuck here :-)
Any hints would be greatly appreciated.