Index exceeds the number of array elements. Index must not exceed 1. cosa posso fare per non far comparire questo errore? N=3 e il vettore w ha 3 elementi
1 回表示 (過去 30 日間)
古いコメントを表示
function [ris] = ordin_genn(w,N)
for i=1:N-1
for j=i+1:N
if w(i)>w(j)
temp=w(i);
w(i)=w(j);
w(j)=temp;
end
end
end
ris=w;
disp("il vettore ordinato è ");
disp(ris);
end
1 件のコメント
Santosh Fatale
2022 年 11 月 9 日
編集済み: Santosh Fatale
2022 年 11 月 9 日
Hi,
What is the relationship between input argument N and dimension of argument w? What is the dimesion of input argument w? I believe w is column vector.
Please correct me if I am wrong in understanding.
回答 (1 件)
Khalid
2022 年 11 月 9 日
Hi massimo,
I understand that you are facing the error for some inputs to the function "ordin_genn".
This error occurs whenever the value of N given to the function is greater than the number of elements in the array w.
So, to resolve this error you are required to give the value of N to be less than or equal to the number of elements in w for the function.
Hope this helps.
Regards,
Khalid
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!