sortrows "not enough input arguments"

Hello all,
Having difficulty using built-in function sortrows... I am attempting to sort a 2-column double array (var "x" below) by col 1 as follows:
x=sortrows(x,1);
Running this line of code returns the following error:
Error using matlab.internal.math.sortrowsParseInputs
Not enough input arguments.
Error in sortrows (line 60)
Notably, I have attempted running sortrows with matrices and other array types/sizes... all to no avail. Any help much appreciated.

댓글 수: 5

In MATLAB R2021a matlab.internal.math.sortrowsHelper is called on lines 59 and 61. But not 60.
So you must have modified the function somehow, or be using another function. Please show the output of this command:
which sortrows -all
Michael Diaz
Michael Diaz 2023년 5월 27일
K>> which sortrows -all
C:\Program Files\MATLAB\R2021a\toolbox\matlab\datafun\sortrows.m
C:\Program Files\MATLAB\R2021a\toolbox\matlab\datatypes\categorical\@categorical\sortrows.m % Shadowed categorical method
C:\Program Files\MATLAB\R2021a\toolbox\matlab\datatypes\tabular\@tabular\sortrows.m % Shadowed tabular method
C:\Program Files\MATLAB\R2021a\toolbox\matlab\datatypes\duration\@duration\sortrows.m % Shadowed duration method
C:\Program Files\MATLAB\R2021a\toolbox\matlab\datatypes\datetime\@datetime\sortrows.m % Shadowed datetime method
C:\Program Files\MATLAB\R2021a\toolbox\matlab\datatypes\tabular\@timetable\sortrows.m % Shadowed timetable method
C:\Program Files\MATLAB\R2021a\toolbox\matlab\bigdata\@tall\sortrows.m % Shadowed tall method
C:\Program Files\MATLAB\R2021a\toolbox\shared\statslib\@dataset\sortrows.m % Shadowed dataset method
Michael Diaz
Michael Diaz 2023년 5월 27일
I am guessing I shadowed a built-in function somehow? I have a copy of sortrows in my "Current Folder" that is different from the path pasted above (C:\Program Files\MATLAB...) -- I am not sure if this might have anything to do with my current issue.
Stephen23
Stephen23 2023년 5월 27일
"I am guessing I shadowed a built-in function somehow?"
Most likely.
"I have a copy of sortrows in my "Current Folder" that is different from the path pasted above"
That would be it.
"I am not sure if this might have anything to do with my current issue."
It is the cause of this issue.
Michael Diaz
Michael Diaz 2023년 5월 27일
Update to all who run into a similar issue in the future -- I did indeed "shadow" the built-in function by having it copied (and possibly edited) into my working directory... deleting the function in my working directory and re-running the code did the trick.
Thanks!

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2023년 5월 27일

0 개 추천

x = randi(99, 5, 2)
x = 5×2
15 86 84 4 59 24 61 78 42 33
x=sortrows(x,1)
x = 5×2
15 86 42 33 59 24 61 78 84 4
Seems to work fine. What did you do differently in the 59 prior lines of code?

댓글 수: 1

Michael Diaz
Michael Diaz 2023년 5월 27일
Kindly see above -- I accidentally shadowed the built-in function!

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 File Operations에 대해 자세히 알아보기

제품

릴리스

R2021a

태그

질문:

2023년 5월 27일

댓글:

2023년 5월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by