0% found this document useful (0 votes)
80 views

Beautify Syms MATLAB Script

The beautify function displays a symbolic expression in a figure window using LaTeX notation. It checks that the input is a symbolic object, converts it to a LaTeX string, adjusts the string formatting, and displays it in a message box with the text area properties adjusted for optimal viewing.

Uploaded by

carsongbaker
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views

Beautify Syms MATLAB Script

The beautify function displays a symbolic expression in a figure window using LaTeX notation. It checks that the input is a symbolic object, converts it to a LaTeX string, adjusts the string formatting, and displays it in a message box with the text area properties adjusted for optimal viewing.

Uploaded by

carsongbaker
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

function beautify(s)

%BEAUTIFY Display a symbolic expression in human readable form.


% BEAUTIFY(S) displays the symbolic expression S in a small figure window,
% using standard mathematical notation.
%
% Examples:
% syms x t positive
% f=taylor(cos(x));
% beautify(f)
% f=int(exp(-t)*t^(x-1),t,0,inf);
% beautify(f)
%
% Required toolboxes: Symbolic Math
%
% See also ...\symbolic\pretty.
% Author: Naor Movshovitz
% May 2006
if ~isa(s,'sym')
error('Argument must be of class ''sym''.')
end
S=['$',latex(s),'$'];
S=strrep(S,'&','& \quad');
S=strrep(S,'{\it','\mathrm{');
h=msgbox(S,'Beautify');
h1=get(h,'children');
h2=h1(1);
h3=get(h2,'children');
if isempty(h3)
h2=h1(2); h3=get(h2,'children');
end
set(h3,'visible','off')
set(h3,'interpreter','latex')
set(h3,'string',S)
set(h3,'fontsize',20)
w=get(h3,'extent');
W=get(h,'position');
W(3)=max(w(3)+10,125);
W(4)=w(4)+40;
set(h,'position',W)
h4=h1(2);
if ~strcmp(get(h4,'tag'),'OKButton'), h4=h1(1); end
o=get(h4,'position');
o(1)=(W(3)-o(3))/2;
set(h4,'position',o)
set(h3,'visible','on')

You might also like