Replace values in matrix
3 次查看(过去 30 天)
显示 更早的评论
Hi everybody I have a matrix, for ex: A=[2 5 7 12 9 4] and another matrix B=[1 4]
ı want to replace elements apart from 1. and 4. as "NaN". (2., 3., 5., and 6., element must be equal to NaN) I tried if command, but i took an error. Is there any pratical command for this operation? Thanks.
0 个评论
采纳的回答
Stephen23
2017-3-6
>> A = [2,5,7,12,9,4];
>> B = [1,4];
>> A(~ismember(1:numel(A),B)) = NaN
A =
2 NaN NaN 12 NaN NaN
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 NaNs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!