MATLAB: How to change a specific number in a specific line in a text file

regexpreptext files

Hi,
I have a txt file and I need to change a specific number in a specific phrase. I want to change the number after the phrase:
UINL_Fuel_C1_Inlet1 56
The number after it as of now is 56 and I want to change it to one of my new values called new_velocity that is calculated in my code. I tried using regexprep but it is not working.
Thanks

Best Answer

filecontent = fileread('YourFileNameHere.txt');
newcontent = regexprep(filecontent,'UINL_Fuel_C1_Inlet1 56', sprintf('UINL_Fuel_C1_Inlet1 %g', new_velocity));
fid = fopen('DifferentFileNameHere.txt', 'w');
fwrite(fid, newcontent);
fclose(fid);