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!