Truncation of a vactor
Mostrar comentarios más antiguos
Hello
I have a vector like this x=[4 7 17 4 6 9 12]
I need to get rid of any values which are higher than 10. I tried this:
for i=1:length(x);
if x(i)>10 x(i)=[];
end
end
This works but with this error message:
'Attempted to access x(7); index out of bounds because numel(x)=5.'
How can I do it without any error message because I need to compute further with x.
Can anyone help?
Kind regards
Sayeed
Respuesta aceptada
Más respuestas (1)
ES
el 8 de Abr. de 2014
Or in other words, you might do
x(x>10)
1 comentario
Mohammad Sayeed
el 8 de Abr. de 2014
Categorías
Más información sobre Loops and Conditional Statements 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!