Issue with summing values within a row of a matrix
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hello,
I've been using matlab to analyse so data that is in the form of a 30 column , many rowed matrix (loaded in via 'load' from a '.txt'file), and example of a row being:
1.00E+00 3.89E-03 1.69E-08 3.56E-04 4.66E-01 5.33E-01 4.44E-04 1.55E-10 4.49E-21 7.83E-36 1.62E-55 2.02E-79 5.9197-109 1.2858-142 9.8305-181 3.4559-234 7.2987-292 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00 0.00E+00
However when I get some wierd results when using this and I think Ive foudn the source of the issue: This data is normalised so that all values in a row sum to 1 (feel free to check in excel or what have you), however when performing a sum of the columns (which is one of the tasks I need to do) such as: 2);
sum(a_data, 2);
I get the value of 17.1830 for the row quoted above... (where a_data is the matrix containing all the rows as shown above)
I have a feeling it is due to the nature of some of the smaller values, however from looking into the documentation, as long as a answer isn't associated to a variable name i.e.
x_data = sum(a_data, 2);
then summing any variable (whether it be double, floating point etc) should be ok?
Any advice on this and maybe a better way to handle such data would be appriciated. Thanks
2 Commenti
Thorsten
il 3 Dic 2015
Modificato: Thorsten
il 3 Dic 2015
In your sample row, some values are given in scientific notation, like 2.02E-79, while others are given as a difference of two values, like 5.9197-109. Is this correct?
I got the result -9.282057099829449e+02 if I sum this row.
and sum(a_data,2) is a sum of the rows, not the columns as you write.
It would be helpful if you post your original data file.
Risposta accettata
the cyclist
il 3 Dic 2015
I spotted some values like
5.9197-109
which I am guessing were supposed to be
5.9197E-109
and I expect that is the source of your problem. Perhaps something went haywire with the data import.
Più risposte (0)
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!