need help vectorizing a loop
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Tyler Davis
el 25 de Nov. de 2013
Respondida: Image Analyst
el 25 de Nov. de 2013
I'm certain that there is a way for me to vectorize this loop but I can't see it
TestRan is a 170x1 double
CorrectVector is a 90x1 double, a subset of TestRan
I need to populate a 170x1 double CorrectLogical with 0/1 based on CorrectVector
what I have:
CorrectLogical = zeros(length(TestRan,1))
for i=1:length(CorrectVector)
CorrectLogical(TestRan==CorrectVector(i)) = 1
end
0 comentarios
Respuesta aceptada
Azzi Abdelmalek
el 25 de Nov. de 2013
Editada: Azzi Abdelmalek
el 25 de Nov. de 2013
CorrectLogical = zeros(size(TestRan))
CorrectLogical(ismember(TestRan,CorrectVector))=1
0 comentarios
Más respuestas (2)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!