corrected format below ---------------------
Is there a way to dynamically trim an N-dimensional matrix into an N-1 matrix given a dimension and the wanted subindex?
I have no knowledge of N before runtime, nor of the dimension on which to trim.
Details:
I need to write a 'trimming' function of the form:
>> data_NDm1 = one_dim_trim(data_ND, 1, a);
% which will allow me to replace any of the
>> data_NDm1 = data_ND(a,:);
>> data_NDm1 = data_ND(a,:,...,:);
% or replace
>> data_NDm1 = data_ND(:,b,:,...,:);% with
>> data_NDm1 = one_dim_trim(data_ND, 2, b);
I have already written a 'cropping' function of the form:
>> data_1D = one_dim_crop(data_ND, [a, NaN, c, ..., z]);
% which takes variable size arguments and replaces:
>> data_1D = data_ND(a, :, c, ..., z);
...but I'm kind of stuck here :-)
Any hints would be greatly appreciated.