Info
この質問は閉じられています。 編集または回答するには再度開いてください。
[Help] syms and file *.txt
3 ビュー (過去 30 日間)
古いコメントを表示
I have a file *.txt with its content
q1 q2 q3 q4 q5 q6 q7 q8 q9 q10
Normally, in [command window] i must type
syms q1 q2 q3 q4 q5 q6 q7 q8 q9 q10
to declatation.
But Now i want to use [command window] to read file *.txt and declaration automatically. I only change file *.txt
0 件のコメント
回答 (2 件)
Walter Roberson
2011 年 11 月 28 日
You could try
vars = regexp( fileread('YourFile.txt'), ' ', 'split');
syms(vars{:});
However, I do not promise that it will work (I cannot test it this evening.) If it does not work, then you will require at least one run-time command evaluation, which is not a good idea.
Have you considered renaming your .txt file as a .m file, adding "syms" to the beginning of the line, and using run() to execute the file as a script?
0 件のコメント
trung trinh
2011 年 11 月 28 日
1 件のコメント
Walter Roberson
2011 年 11 月 28 日
Does your text file contain other things as well? If so then the fileread() would have to be replaced with code that read just the first line of the file.
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!