Borrar filtros
Borrar filtros

Code works until I iterate too many times and/or increase value too many times

2 visualizaciones (últimos 30 días)
Problem is I'm adjusting values in a 5x5x5 matrix and if we look in the first set of values (:,:,1) there are 25 values there (wrong values that got corrupted) plus a value above them saying 1.0e+03 *. The issue is not the format of the answers but that there are 26 values there and they have been corrupted.
I have a loop of code that loops about 63,000 times and a loop inside that that checks to see if a threshold has been reached and if so increments a counter in 5x5x5 structure. If threshold is low the counter increments about a thousand times and the 5x5x5 structure values go crazy, image. Notice in the screen shot of the 5x5x5 structure for the first set of values (:,:,1) there is the 5x5 data PLUS a 1.0e+03 and it has messed up the other values in that 5x5 section?!
I'm trying to figure out if it is a Matlab bug or if there is something I'm doing wrong. Thank you!
  3 comentarios
Brent
Brent el 9 de Abr. de 2016
Hi Azzi,
Thank you for looking at the issue. I've added more details. If you look at the screenshot there should be 5x5=25 values in each section but there are 26 (1+5x5) and the values have been corrupted. The code works perfect if I lower the number of iterations or increase a threshold value so it doesn't increment a cell in the matrix as much but since I'm only iterating 65000 times and incrementing about a thousand times, it isn't clear what limit is being reached.
Walter Roberson
Walter Roberson el 9 de Abr. de 2016
The 1.0e+03 is not a 26th value: it is a scaling factor that is being printed out by "format short" to try to be able to fit values in compactly. "format long g" will use more screen space but will not show up like that.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 9 de Abr. de 2016
format long g
and try the calculation again
  3 comentarios
Walter Roberson
Walter Roberson el 9 de Abr. de 2016
1.0e+03 * is not a 26th value: it is a scale factor that "format short" uses for a compact display.
Look:
>> format short
>> 10.^(1:8)
ans =
10 100 1000 10000 100000 1000000 10000000 100000000
>> 10.^(1:9)
ans =
1.0e+09 *
0.0000 0.0000 0.0000 0.0000 0.0001 0.0010 0.0100 0.1000 1.0000
the values are not being corrupted, they are being abbreviated to fit into a small area. The 1.0e+09 * means that you need to mentally multiply what follows by 1.0e+09
Let me put it another way: if you only have about 8 characters for every field output, how would you like it to represent a range that varies by a factor of more than 10^6 ?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by