element by element division of two matrices not producing expected result
조회 수: 2 (최근 30일)
이전 댓글 표시
Dear Matlab community,
I have two large matrices. I would like to calculate the percentage reduction, as each matrix represents values at two time points (for example let's name them matrix1 and matrix2).
Accordingly, I would like to do the following operation: ((matrix1 - matrix2) ./ matrix1) x 100
The subtraction works as expected. For example, the very last element is: -0.9107 - (-0.4302) = -0.4806
However, when then dividing this subtraction matrix by matrix 1, all the elements are around 0.0001.
The last element should be equal to 0.5276 before being multiplied by 100.
Any suggestions as to what I may be doing wrong?
Thank you.
댓글 수: 0
채택된 답변
Matt J
2020년 10월 10일
편집: Matt J
2020년 10월 10일
I suspect you are simply being confused because Matlab is displaying everything in 4-decimal scientific notation, such as in the following:
>> [10000,0.5]
ans =
1.0e+04 *
1.0000 0.0001
If you didn't see the 1.0e+04 out front, you might think the second number was 0.0001.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!