MATLAB: How to find a specific string in a text file and delete that row

text file

Hi
I have text file that includes a register with personnumbers and names of peoples. I want to be able to edit that textfile by giving the code the name as a string input, and the code deletes the corresponding row to that name.
I have looked around, but I can't find any good example for this. Thank you for your help.
Regards

Best Answer

Look at the help for fgetl(). Just open the file, read line by line, for each line, use strfind() or strcmpi() to check the line against your template, and if it's not the template, write it out to another file. Then you can delete the first file and rename the output file the same as your original input file. Come back with your code if you still have problems, but at least give it a try yourself - like I said, the help has sample code for you.