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;
本文介绍了一个MATLAB函数,用于从矩阵中删除指定列,并提供了详细的实现步骤。该函数通过遍历指定要删除的列索引,逐个移除矩阵中的相应列,最终返回处理后的矩阵。
5万+

被折叠的 条评论
为什么被折叠?



