I currently have the following code with the help of Stephen Cobeldick:
function myopen( str )cd '[location to folder where search is taking place]';S = dir(sprintf('*%s*.txt',str));cellfun(@winopen,{S.name});cd '[location to current folder where matlab file is located]'end
This code will open a file when part of the file name is entered. 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.
Now what I am trying to do is to find a way when the user enters two or more words the code should open the file which has both the words. I tried to manipulate the code a bit but was not able to.
For Example: The files present are cats_dogs_lions.txt , cats_cheetah_goat.txt and cats_hyenah_dog. I want to write a code which will allow the user to open a file which will open the file cats_dogs_lions.txt if the user enters cats & lions and will open the file cats_cheetah_goat.txt if the user enters cats & cheetah.
Thanks in advance!
Santi
Best Answer