MATLAB: How to open a file if the user enters part of the file name

keywordopensearchwinopen

I am trying to write a code that will allow the user to enter a 'keyword'. The code should then search for a file which has that keyword in it and open it using a windows software. I know I have to use winopen() function but I am not able to figure out the first part of the problem.
For example: If the user enters cat and the files available are 1) cat_dog_bird.txt 2) cheetah_lion_tiger.txt and 3) shark_whale_dolphin.txt the code should open the cat_dog_bird.txt file in a notepad editor (a windows software).
If the user enters dog then the code should still open the cat_dog_bird.txt file in a notepad editor.
Thanks in advance!
Santi

Best Answer

This works for me:
function myopen(str)
S = dir(sprintf('*%s*.txt',str));
cellfun(@winopen,{S.name});
end
and tested:
>> myopen('cat')
opens the file cat_dog_bird.txt using Notepad++ (being the default text editor on my computer (because it is much better than Notepad)).