How can I edit a '.m' file by another '.m' file ?

81 views (last 30 days)
Can we edit a '.m' file from another '.m' file ? Like we can modify/update a model and save it by a M script.

Accepted Answer

Image Analyst
Image Analyst on 18 Feb 2017
Yes. Open it with fopen(), get lines out into strings with fgetl(), modify them as needed. Open an output file with fopen(), write the modified lines out. Close both files with fclose(). Delete the input file with delete(). Rename the output file to the input filename with movefile().
  7 Comments
BABANBHAIGARI SHAFIULLAH
BABANBHAIGARI SHAFIULLAH on 31 Aug 2021
It worked for me. Thank you @Image Analyst for the detailed explanation.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!