您的位置:首页 > 编程语言 > MATLAB

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

2011-03-09 20:03 429 查看
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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: