Store NaN and remove in for loop
显示 更早的评论
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
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!