Converting a complex number into a single value
6 次查看(过去 30 天)
显示 更早的评论
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 个评论
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 Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!