Index 1 Variable by another
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hillaryfor2016
el 12 de Abr. de 2015
Comentada: Star Strider
el 12 de Abr. de 2015
Hi there!
I have 2 variables
if true
A = 1
2
NaN
4
end
B= 20
2
5
4
end
I want to remove the '5' from variable B by replacing it with a NaN (i.e. any NaN's in variable A result in a NaN in variable B
I understand this is a simple problem. I have researched but its been a long day Please help x
0 comentarios
Respuesta aceptada
Star Strider
el 12 de Abr. de 2015
Use ‘logical indexing’:
B(isnan(A)) = NaN
produces:
B =
20
2
NaN
4
2 comentarios
Más respuestas (0)
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!