I want to build a function that can extract sub-matrix according to user input. Like the one shown below.
function newMatrix = extractMatrix(matrix,dim,index) if dim == 1 newMatrix = matrix(index,:,:,...); elseif dim == 2 newMatrix = matrix(:,index,:,...); elseif ... endend
Since the length(size(matrix)) is also a variable, the conditional statement seems also not working here. What is the possible way for implementing such function?
Best Answer