How can I sort data in increasing order
이전 댓글 표시
I have been given this data

I want to classify the length in each row as either the shortest(S), longest(L), or other (P or Q) so i can use this equation S+L=P+Q

Here is my code so far.
댓글 수: 3
the cyclist
2021년 9월 24일
In the future, please don't post an image of your code. We can't work with that if we want to try out your code, and would need to retype it all.
Instead, use the CODE button to format code text, or upload an m-file with the code.
JAKE WISNIEWSKI
2021년 9월 26일
Image Analyst
2021년 9월 27일
@JAKE WISNIEWSKI, Why can't you do it now? All I can suggest is to use sort() or sortrows(). And I'm not sure I buy this equation
S+L=P+Q
What makes you think it will be true? For example for one row where the L's are [6,2,7,9] you have
2 + 9 = 6 + 7
or
11 = 13
which is obviously not true.
답변 (1개)
Sulaymon Eshkabilov
2021년 9월 24일
0 개 추천
Use sort() that sorts in an ascending order and then take the indexes that will be used for the others, OR put in a table using array2table() and sort them in order.
카테고리
도움말 센터 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!