element by element division of two matrices not producing expected result

2 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Matt J
Matt J il 10 Ott 2020
Modificato: Matt J il 10 Ott 2020
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.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by