搜索一个数组里面的 数值问题、。

limit =
【1108.9 600
958.93 600
958.93 148.29
981.3 228.89
1111 228.89
1111 169.09
1192.2 169.09
1258.9 235.67
1258.9 600】
b=1111 228.89;
b是经过运算算出来的
a=find(ismember(limit,b,'rows'));
为啥显示a为空集呢
要是单独运行的话可以 得出a的值为5 但是放到主函数循环里面 a就是空集了
这是为什么呢 求大神知道
急 坐等您的回答

 采纳的回答

dinaj
dinaj 2022-11-20

0 个投票

ismember这个函数不能用了吧,可以用设定一个容差值:
limit =[1108.9 600
958.93 600
958.93 148.29
981.3 228.89
1111 228.89
1111 169.09
1192.2 169.09
1258.9 235.67
1258.9 600]
b=[1111+eps(1111) 228.89];
% ismember(limit,b,'rows')
k=bsxfun(@minus,limit,b);
w=abs(k)<1e-8; %1e-8为容差值
find(all(w,2))

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 数学 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!