what it does mean?
Mostrar comentarios más antiguos
If index(1,1)==1
S1=0;
S2=1;
end
Respuestas (2)
Cris LaPierre
el 12 de En. de 2021
2 votos
David Hill
el 12 de En. de 2021
If the matrix 'index' indexed at (1,1) equals 1, then assign S1 =0 and S2 = 0.
if index(1,1)==1
S1=0;
S2=1;
end
2 comentarios
Nyam Jargalsaikhan
el 12 de En. de 2021
Editada: Nyam Jargalsaikhan
el 12 de En. de 2021
David Hill
el 12 de En. de 2021
Matlab has good documentation. You should look at the sort() function.
help sort
You will see that the index array contains the index numbers for rearraigning A to sort it.
A(index)==sort(A);
The code above seems poorly written. First, index is only one dimension, so you only need to index at (1). Second, all if statements do the same thing so combining them into a single statement would be better.
A=[1 5 7 8 4 2 6 3];
[~, index]=sort(A);
if ismember(index(1),[1 2 3])
S1=0;
S2=0;
end
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!