matlab里删除矩阵一些列的函数

 

function matrix = deleteMatrixColumn(matrix,index,numRow)

index = sort(index);

lastIndex = 0;

tempMatrix = [];

for i=1:size(index,2)

    if index(i)==1

       lastIndex = 1;

    elseif index(i)==size(matrix,2)

       break;

    else

       tempMatrix = [tempMatrix matrix(1:numRow,lastIndex+1:index(i)-1)];

       lastIndex = index(i);

    end

end

if lastIndex<size(matrix,2)

   tempMatrix = [tempMatrix matrix(1:numRow,lastIndex+1:end)];

end

matrix = tempMatrix;

 

你可能感兴趣的:(function,matlab,Matrix)