Save Sym data per variable
古いコメントを表示
Hello, I have a code which deals with symbolic variables and I have as output a vector whose dimension is known but variable.
The output is symbolic, for example a=[y_1/3+y_2/5 y_1/10+y_2/37]
I would like to save in an ASCII file, not binary, the output and for each row have one element of the vector. The tricky part is the saving in a file, I can do it only in bin, since when I type -ASCII it doesn't do it.
Here I attach a piece of code useful to understand. Thanks for your time.
Antonio
syms a b c x;
results=solve('a*x^2 + b*x + c');
save results.dat results
My output comes as:
results=[-(b + (b^2 - 4*a*c)^(1/2))/(2*a) -(b - (b^2 - 4*a*c)^(1/2))/(2*a)]
採用された回答
その他の回答 (2 件)
Walter Roberson
2011 年 10 月 5 日
results = char(solve('a*x^2 + b*x + c'));
3 件のコメント
mortain Antonio
2011 年 10 月 5 日
Walter Roberson
2011 年 10 月 6 日
This is not something I can test myself, but I can tell you that that output does not look as expected and documented.
mortain Antonio
2011 年 10 月 7 日
Shahram Alipourazadi
2011 年 10 月 22 日
To isolate each row you can write:
fid = fopen('myfile.txt', 'w');
for i=1:length(results)
fprintf(fid, '%s\n',char(results(i)));
end
fclose(fid);
Generally first you should convert each argument into string and then using string manipulation functions arrange them
カテゴリ
ヘルプ センター および File Exchange で Creating, Deleting, and Querying Graphics Objects についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!