If isnan(x) make columns also NaN
2 次查看(过去 30 天)
显示 更早的评论
I have a horizontal array or data 1:1505 made of Nans and 1s (inA4)
I also have a matrix of data 96:1505 (Approx4)
Where ever a NaN appears in 'inA1' I want the entire column of Approx 1 to become NaNs.
This is what I have come up with so far, but It's not working. I'm sure the solution is simple but I can not work it out thus far
for i = 1:96;
j = 1:1505;
if inA4(j) == 1;
Approx4(i,j) = Approx4(i,j);
else isnan(Approx4(i,j));
end;
end;
0 个评论
回答(2 个)
Wolfgang
2016-2-10
idxNaNs = isnan(inA4); % find NaNs in inA4
Approx4(:,idxNaNs) = NaN; % set columns to NaN
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!