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.

采纳的回答

Matt J
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 CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by