How can I read/write .txt file on Simulink environment?
17 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Damdae
am 5 Feb. 2017
Kommentiert: Walter Roberson
am 4 Aug. 2021
As you might know, there is no block for reading or writing data to .txt format in Simulink model library. (PLEASE DO NOT tell me use .mat format instead of it)
So I firstly used Interpreted MATLAB Function containing fopen, fprintf, and fscanf codes inside.
However, I found that it triggers saving 0 values at initialization stage.
This lead me to think of using the S-function block, which seems to can handle initialization stage separately so that I can neglect the saving procedure at initialization stage.
Is there any source file or even a link that I'm looking for?
0 Kommentare
Akzeptierte Antwort
Ankit Bhatnagar
am 8 Feb. 2017
There is no way available to write to a text file directly in Simulink. You can use the "To Workspace" block or "To File" (a .mat file) to store what data you want to.
Then with that data, you can use save() in Command Window to save the data to a text file as shown:
save File Data -ascii
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu String finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!