Debugging a piece of code
조회 수: 1 (최근 30일)
이전 댓글 표시
I have been trying to run a piece of code written in Matlab that contains the following:
function list = shellsort(list);
interval = floor(length(list)/3);
I get the following error message:
Not enough input arguments.
Error in shellsort (line 3) interval = floor(length(list)/3);
Any ideas on how to debug it?
댓글 수: 0
답변 (2개)
Walter Roberson
2020년 11월 3일
When you press the green Run button, what is your expectation about where MATLAB will search for the value of the variable named list ?
댓글 수: 2
Walter Roberson
2020년 11월 5일
You are pressing the green Run button to initiate the code. MATLAB needs to know the value of the variable named list in order to proceed. Where are you expecting MATLAB to look to find the variable named list?
Monika Jaskolka
2020년 11월 3일
How are you running the shellsort function? From the error message you provided, it looks like you are not giving shellsort any input parameters
% Incorrect
>> shellsort
Not enough input arguments.
Error in shellsort (line 2)
interval = floor(length(list)/3);
% Correct
>> shellsort(list)
ans =
1 2 3
댓글 수: 15
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!