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 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commento
Santosh Fatale
il 9 Nov 2022
Modificato: Santosh Fatale
il 9 Nov 2022
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.
Risposte (1)
Khalid
il 9 Nov 2022
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 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!