数学建模社区-数学中国's Archiver
论坛
›
MATLAB论坛
› 怎样编程让一组数更接近a值为0更接近b值为1
duolalamen
发表于 2016-7-25 16:22
怎样编程让一组数更接近a值为0更接近b值为1
怎样编程让一组数更接近a值为0更接近b值为1
愚庸
发表于 2016-7-25 18:01
首先要把接近的概念定义好,有两种思路。
假设这组数据为c,1、if abs(c-a)>abs(c-b) then c=1 else c=0 end;
2、if abs(c-a)<=1 then c=0 else if abs(c-b)<=1 then c=1 end;
主要结合你的业务实际去考虑吧。
页:
[1]
查看完整版本:
怎样编程让一组数更接近a值为0更接近b值为1