How to overwrite the array elements of File2.m in File3.m in matlab?See the details

1 vue (au cours des 30 derniers jours)
Support required:
1.I need to write a script in File3.m.
2.I need to open the File2.m (By path)
3.I need to overwrite the File2.m file's A1(2:4) based on cal(19:21) every time.
4.I need to save the File2.m
Thanks in advance
Noohu.

Réponses (1)

Steven Lord
Steven Lord le 14 Juil 2020
I recommend against storing your data in a program file and trying to modify the file like this. Instead store your data in a data file (like a MAT-file) that you can load and save.
If you must do this: read in file2.m as text using the file I/O functions. Modify the text in memory; the text data manipulation functions may be of use to you. Write the modified text back to file2.m using the file I/O functions.
  1 commentaire
Mohamed Noohu Lebbai
Mohamed Noohu Lebbai le 15 Juil 2020
Hi Steven,Thanks for sharing
I recommend against storing your data in a program file and trying to modify the file like this. Instead store your data in a data file (like a MAT-file) that you can load and save
Regarding highlighted lines:Currently i am working in exisitng script so couldnt change the process.
Finally i need to create an .mfile(File2.m) with values based on cat.m-->this could be done by File3.m's script.
This created File2.m will feed into the different tool,So .mfile format with actual values are important.
Request your gudness.
Regards,
Noohu

Connectez-vous pour commenter.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by