unique() function not working in external mode
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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?
Risposte (1)
Guillaume
il 6 Set 2017
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 Commenti
Vedere anche
Categorie
Scopri di più su Target Computer Setup in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!