element by element division of two matrices not producing expected result
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Prabhjot Dhami
il 10 Ott 2020
Commentato: Prabhjot Dhami
il 10 Ott 2020
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 Commenti
Risposta accettata
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)
Vedere anche
Categorie
Scopri di più su Matrix Indexing 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!