problem in initializing sparse matrix
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I encountered this strange counter intuitive thing, a = 150e-6; b = 1e3; c = 1e4;
d = a*b*c; % now d = 1500 is definitely an integer mathematically but A = sparse(2*d,2*d) says "Error using ==> sparse Sparse matrix sizes must be non-negative integers less than MAXSIZE as defined by COMPUTER. Use HELP COMPUTER for more details."
d is displayed as 1.500000(couple of more zeors)e+003. it is equal to 1500. i tried forcing by int32(); then another error comes. but initializing A = sparse(2*1.5e3,2*1.5e3) does fine. any clue what i'm missing. many thanks for the help on this strange issue. I guess i'm missing some thing obvious but can't catch it.
0 Kommentare
Akzeptierte Antwort
Youssef Khmou
am 8 Mai 2013
hi,
it worked well, no problem and d=1500, try to use of these functions :
d=floor(d);
d=ceil(d);
d=round(d);
2 Kommentare
Youssef Khmou
am 8 Mai 2013
maybe the reason is : it is written in the documentation of 'int32()' that If the stored integer word length is too big for an int32 the returned value saturates to an int32, "saturates", but not rounded .
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!