Display Interpreted Latex string outside a plot
조회 수: 49 (최근 30일)
이전 댓글 표시
Hi there,
I want to show in my output (not in my plots) the handwritten format of my expression. I have the symbolic toolbox.
% No problem in plots, simple example
x=linspace(0*deg,360*deg,360); % deg is constant in my installation
f='sqrt(abs(sin(x.^2)))'; ff = eval(f);
p=plot(x,ff);
title(['Title ' '$' latex(str2sym(f)) '$'] , 'Interpreter', 'latex');
Now suppose I don't need a plot of any kind and I want to check if I made a mistake in a long expression or equation.
I'd like to show the hand written format of my expression
Refering to the little code over
If I type ['$' latex(str2sym(f)) '$']
I will get the Latex representation ans = '$\sqrt{\left|\sin\left(x^2\right)\right|}$'
Now I want to do this something like this
disp(['$' latex(str2sym(f)) '$'] , 'Interpreter', 'latex');
and get

Can I do something like this ? Not with disp(...) for sure !
댓글 수: 3
채택된 답변
madhan ravi
2020년 7월 18일
sympref('TypesetOutput','default')
f = str2sym('sqrt(abs(sin(x.^2)))') % gives the desired result in livescript
댓글 수: 2
madhan ravi
2020년 7월 18일
You don’t have to be ashamed of asking a question. By the way please don’t use eval() it’s completely unnecessary.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
