Issue with summing values within a row of a matrix
조회 수: 1 (최근 30일)
이전 댓글 표시
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
Thorsten
2015년 12월 3일
편집: Thorsten
2015년 12월 3일
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.
채택된 답변
the cyclist
2015년 12월 3일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!