Replace a parameter’s value inside text file with MATLAB

Spread the word!

Assuming we file.txt, which looks like this:

Task: open file.txt in Matlab, change the value corresponding to KEY8 (which is “VALUE8”) to e.g. “NEW VALUE8” and save the new version as file_after.txt.

General assumptions:

  • Keys and values are separated by spaces (no matter how many).
  • The pair key-value are divided by (at least) a new line.

Be the first to comment

Leave a Reply

Your email address will not be published.


*