How can i solve it
>> TourLength Not enough input arguments. Error in TourLength (line 3) n=numel(tour);
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
function L=TourLength(tour,model)
n=numel(tour);
tour=[tour tour(1)];
L=0;
for k=1:n
i=tour(k);
j=tour(k+1);
L=L+model.d(i,j);
end
end
2 Kommentare
Askic V
am 2 Dez. 2022
Most probably you're trying to execute this as a Matlab script and not as a function. You need to properly call the function from command window or from the other script (or function) with specified arguments.
Antworten (2)
Gokul Nath S J
am 7 Dez. 2022
Hi Wonseh,
As per my understanding, you have created a function TourLength containing 2 input arguments. If you directly run this function in MATLAB by clicking the run button, you will encounter a similar error. For example, if executing from the command window you might need to enter the following command
TourLength(input_argument1, input_argument2);
Also, you might need to ensure that the arguments passed as the function parameters are appropriate. Inappropriate arguments can also lead to numel error.
0 Kommentare
Siehe auch
Kategorien
Find more on Programming Utilities in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!