Converting a complex number into a single value

8 ビュー (過去 30 日間)
NC
NC 2018 年 6 月 12 日
コメント済み: Rik 2018 年 6 月 13 日
I have got a matrix of complex values and I want to sort the highest 10 values from it. For this I got the modulus of the complex values and the sorted them. But the values I get after applying modulus change from time to time. How to solve this to get a consistent value? I'm using Matlab IDE.
Code segment used.
realPeriodicityMap = abs(periodicitymap);
disp(realPeriodicityMap);
periodicitymapRow = reshape(realPeriodicityMap, 1, []);
Changes in values are shown below. Instance 1 values:
0.0040 0.0047 0.0014 0.0067 0.0040 0.0023 0.0030
0.0054 0.0040 0.0016 0.0040 0.0078 0.0087 0.0057
0.0054 0.0044 0.0068 0.0040 0.0048 0.0023 0.0012
0.0061 0.0040 0.0032 0.0002 0.0055 0.0055 0.0045
Instance 2 values:
0.0046 0.0045 0.0016 0.0067 0.0037 0.0021 0.0027
0.0057 0.0043 0.0018 0.0044 0.0077 0.0085 0.0051
0.0091 0.0054 0.0051 0.0070 0.0042 0.0051 0.0018
0.0062 0.0038 0.0034 0.0004 0.0056 0.0053 0.0043
  4 件のコメント
NC
NC 2018 年 6 月 13 日
Yes, same input gives different outputs. I tried your code and it sorts 10 values successfully. But the changes in values is still there.
Rik
Rik 2018 年 6 月 13 日
So running the exact same code produces 2 different results, without any other code being run in between? That would mean the code below would result in false:
sorted=sort(abs(realPeriodicityMap),'descend');
A=sorted(find(sorted, 10));%get top 10 values
sorted=sort(abs(realPeriodicityMap),'descend');
B=sorted(find(sorted, 10));
isequal(A,B)
Can you confirm this?
Are you also sure you didn't make a typo interchanging periodicitymap and realPeriodicityMap? And do you have any m-lint warnings in that piece of code?

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by