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

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就是空集了
这是为什么呢 求大神知道
急 坐等您的回答

 Akzeptierte Antwort

dinaj
dinaj am 20 Nov. 2022

0 Stimmen

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))

Weitere Antworten (0)

Kategorien

Mehr zu 数学 finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 20 Nov. 2022

Beantwortet:

am 20 Nov. 2022

Community Treasure Hunt

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

Start Hunting!