如果我的输入矩阵是:
v =
-0.7071 0.5774 0.4082
0.0000 -0.5774 0.8165
0.7071 0.5774 0.4082
输出应为:
v =
-1 1 1
0 -1 2
1 1 1
答案 0 :(得分:2)
[A,B] = size(v)
for ii = 1:B
v(:,ii) = v(:,ii)./abs(min(v(:,ii)));
end
如果这是您的确切示例。
以防双打不够好:
v = int32(v); % or whichever integer you want
bsxfun
方式,感谢@rayryeng:
v = bsxfun(@rdivide, v, abs(min(v,1)));