What command does the same as find but including null elements?
Mostrar comentarios más antiguos
So this exercise asks you order any vector in a manner such that the minor elements are on the front and the major elements on the back.
Its pseudo code goes like this:
Ordering of a vector (x1, x2, . . . , xn) by selection
for i ranging from 1 to n-1
k ← i
for j ranging from i + 1 to n
if xj < xk
then k ← j
end of cycle in j
t ← xi
xi ← xk
xk ← t
end on cycle in i
Then you are asked to create a code that does the same in Matlab. Here's what i've got for starters:
v = input( 'vector? ' )
for v(1:end)
k = find(v)
My problem is that find ignores the elements that are equal to zero. That would screw up my ordering. So what command does the same as find while taking the zeros into consideration?
2 comentarios
madhan ravi
el 21 de Dic. de 2018
what's the input and your desired result?
bobsoney bobsoney
el 21 de Dic. de 2018
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Programming 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!