Converting string scalar to written code
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Burçak
am 11 Dez. 2023
Kommentiert: Burçak
am 12 Dez. 2023
Is there a way to convert a string (suppose you have a variable str = "case 'newcase', x = 5; ") into written code in a script (not only to execute it) ?
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 12 Dez. 2023
You can write text to a file using writelines() or by using fopen() / fprintf() / fclose(), or by using fopen() / fwrite() / fclose()
str = "case 'newcase', x = 5;"
writelines(str, 'testscript.m');
dbtype testscript.m
If you are wanting to write text into the middle of an existing file then unfortunately it gets a little more complicated.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu String Parsing 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!