Replacing specific rows in a matrix.
1 次查看(过去 30 天)
显示 更早的评论
I would like to replace the cells with the following features (those whose types are 9 or 12 and their ID is one of these numbers, 2,11,12). Then I want to replace them with NaN. However, indexB is a vector of 0 s only.
indexB = ( (Type == 9|Type ==12) & (IDscript ==2|IDscript==11|IDscript==12) );
RT(indexB)=NaN;
2 个评论
James Tursa
2018-5-10
Have you looked at your data to make sure you have any spots that match all of the criteria?
采纳的回答
sloppydisk
2018-5-10
a = xlsread('Book2.xls');
indexB = (a(:, 2) == 9|a(:, 2) ==12) & (a(:, 6) ==2|a(:, 6)==11|a(:, 6)==12);
find(indexB)
This gives me 6 indices: 29, 30, 363, 364, 573 and 574.
2 个评论
sloppydisk
2018-5-10
The idea is the same but is mergedData just a 748x6 double? What is the data type of "Type" and "IDscript"?
更多回答(1 个)
Elaheh
2018-5-10
1 个评论
sloppydisk
2018-5-10
Yeah that should work. You can attach the script if it's still not working for you.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 NaNs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!