MATLAB submatrix over variable dimensions
- by rlbond
I have a variable dimension matrix, X. I want a function that will get the first half of X in one dimension. I.E., I want something like this:
function x = variableSubmatrix(x, d)
if d == 1
switch ndims(x)
case 1
x = x(1:end/2);
case 2
x = x(1:end/2, :);
case 3
…