unique() function not working in external mode
8 ビュー (過去 30 日間)
古いコメントを表示
I am using Simulink real-time on a target computer. I have a piece of code that seems like it should work, and works when I run it locally, but it doesn't work on the target.
coder.varsize('uniqueRows',[100 3])
uniqueRows = unique([V1,V2,V3],'rows');
where V1, V2, and V3 are constant parameters and are always column vectors of doubles of size [100,1]. It always thinks all 100 of 100 rows are unique, when they are actually not. Any ideas?
回答 (1 件)
Guillaume
2017 年 9 月 6 日
I found the cause of the problem: unique() can't tell that two zeros are the same
More likely, your two zeros are not the same and slightly different from zero (at least one of them) but also much smaller than eps(1). Then when you add eps(1) to your not-exactly-zero that small difference gets cancelled by the massive increase in magnitude.
e.g:
v = [1e-307, 1e-306]
unique(v) %values are not equal
unique(v+eps) %values are equal because the minute difference gets cancelled by the massive increase in value
2 件のコメント
参考
カテゴリ
Help Center および File Exchange で Target Computer Setup についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!