reordering structure based on the content of one field

조회 수: 9 (최근 30일)
Abdelwahab Fawzy
Abdelwahab Fawzy 2016년 12월 30일
답변: Image Analyst 2016년 12월 30일
if there is a structure (S) for 10 nodes. the three fields of the structure are (xd , yd and ID) where,,
S.xd ==> X-dimension , S.yd ==> Y_dimension , S.ID ==> node's order or its ID , S.E ==> Energy
I wanna reorder the structure of these nodes based on their residual energy

답변 (1개)

Image Analyst
Image Analyst 2016년 12월 30일
Maybe this:
se = [S.E]; % String together all S.E items.
% Now sort in ascending order
[sortedSE, sortIndexes] = sort(se, 'ascend');
% Now sort the structure array.
S = S(sortIndexes);

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by