Compare value in one column and replace string in another column
2 次查看(过去 30 天)
显示 更早的评论
Dear all,
I imported a very long logfile with textscan using the %s (string) for all columns, given that I have both strings and numbers within column:
M =
{20132x1 cell} {20132x1 cell} {20132x1 cell} {20132x1 cell} {20132x1 cell}
In column 5 I have reaction time data. I column 3 I have "hit", "miss" or "correct" labels. I would like to clean my data, so that whenever column 5 has a value below 2000 ms or above 40000 ms the correspondent column 3 would be replaced with 'miss'.
I introduced a loop alpha declaring the size of M (I need this loop for additional operations), and between this loop I would like to clean the data:
for alpha = 1:size(M{1},1)
%idea which doesn't work
if str2num(M{5}{Z2}) <= 2000; change to 'miss' in M{3}}{Z2}
if str2num(M{5}{Z2}) >= 20000; change to 'miss' in M{3}}{Z2}
end
Any suggestion would be highly appreciated.
Sincerely,
Udiubu
0 个评论
回答(2 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!