string match and replace string with matching number from another matrix
2 次查看(过去 30 天)
显示 更早的评论
Hi All,
I'm stuck. I have a file called StimNo.mat that contains the filenames of over 2000 soundfiles (e.g. 'air.wav', 'air_2.wav', 'chair.wav' etc) in the first column. The second column has the associated number (e.g. 1, 2, 3 etc).
I have another file like it with a small subset of the .wav names. I'd like to replace the names of the .wav file with the number from Column 2 in StimNo.mat. How might I do that please? The .wav files are not consistently labeled so need to match the full string.
Kind regards
Phil
0 个评论
采纳的回答
Paul
2023-11-27
编辑:Paul
2023-11-27
From the desription, it sounds like the StimNo file contains a cell array (assuming all file names are unique)
stimno = {'air.wav' 1;'air2.wav' 2;'chair.wav' 3;'chair2.wav' 4}
and the second file is something like
secondfile ={'chair2.wav'; 'air2.wav'}
And the result would be
[~,locb] = ismember(secondfile,stimno(:,1));
locb
result = stimno(locb,2)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 String 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!