converting symbolic to string and printing to a file without 'piecewise' expression
조회 수: 3 (최근 30일)
이전 댓글 표시
I am attempting to print a symbolic expression to a file as a string. This piece of code worked correctly for me and then for some unknown reason didn't:
fprintf(fid,'''%s'';\n\n',char(C(i,j,2)));
By working correctly i mean that it printed out without a 'piecewise' in front of it...Does anyone know why its all of a sudden printing the output as 'piecewise'.
Thanks
댓글 수: 0
답변 (1개)
Walter Roberson
2011년 5월 25일
What does disp(C) show you ? If there is a conditional portion to the expression, it should show you piecewise(). Unless, that is, you want the formatted multi-line version that shows one case per line.
Possibly evalc(C(i,j,2)) would be useful for you
댓글 수: 3
Walter Roberson
2011년 5월 25일
If you are printing a large symbolic matrix to a file so that you can use eval(), then you should consider instead using matlabFunction() to convert the matrix to a function handle or to write the function body to a file.
참고 항목
카테고리
Help Center 및 File Exchange에서 Symbolic Variables, Expressions, Functions, and Preferences에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!