フィルターのクリア

element by element division of two matrices not producing expected result

1 回表示 (過去 30 日間)
Prabhjot Dhami
Prabhjot Dhami 2020 年 10 月 10 日
コメント済み: Prabhjot Dhami 2020 年 10 月 10 日
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.
  1 件のコメント
Prabhjot Dhami
Prabhjot Dhami 2020 年 10 月 10 日
You are exactly right. This is a bit embarrassing...
Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by