issue when creating a long vector
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I'm trying to interpolate a huge vector, and I got a problem. Here it is:
numel(unique(diff(1:2e-5:30))) is not equal to 1 ! That means that when I ask matlab to create a vector, it does not always have the same difference between each value.
It's pretty anoying, since in ordre to make the interp1 works, apparently I need that!
It could be related to the double, but I double that.
In any case, this is pretty annoying. What should I do?
(ps: using matlab 2012b)
0 Commenti
Risposte (2)
Azzi Abdelmalek
il 16 Mag 2014
like you mentioned it, it has to do with the ways that floating numbers are stored in memory. You can't do anything about that. Read http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F
0 Commenti
Jos (10584)
il 16 Mag 2014
You can scale the values before you use interp1. Something along these lines:
xi = 1:60e5;
x_scaled = x * 1e5 ;
yi = interp1(x_scaled, y , xi)
0 Commenti
Vedere anche
Categorie
Scopri di più su Logical 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!