How can i scale certain values in a vector?
显示 更早的评论
I have a certain vector with data and now i want to scale all values below 0 to values between -1 and 0 and all values above 0 i want to scale to values between 1 and 0.
So i have a vector A All the values below 0 (<0) i want to devide by a certain value all the values above 0 (>0) i want to devide to another certain value all the values which are 0 should stay 0.
Is this possible to do with matlab?
采纳的回答
更多回答(1 个)
dpb
2015-3-26
ix=x>0; % logical vector +ive loc's
x(ix)=x(ix)/max(x(ix)); % normalize +ive
x(~ix)=x(~ix)/max(abs(x(~ix))); % normalize -ive
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!