Store NaN and remove in for loop
Mostrar comentarios más antiguos
Essentially, I have two arrays of the same size, one contains some NaNs and I want to remove the corresponding points in the second array
I have the equation:
SOAM = nansum(CP(1:(n-3)))/sum(norm(fixed_xyz(2:n,:)-fixed_xyz(1:n-1,:)));
- CP contains values from 0-180 with some NaN size = 100,3
- fixed_xyz contains binary values with no Nan size = 100,3
Using "nansum" you can ignore NaNs but I want to avoid the corresponding points in the array "fixed_xyz".
i.e.
for k = 1:size(CP)
if CP(k) = NaN
CP(k) = []
fixed_xyz(k) = []
end
end
Trouble with this is that the loop reduces the size of CP making the itteration of the for loop over step the actual size and an error occurs.
How can I get around this? Is there a simpler notation for this?
Cheers, Will
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Logical 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!