MATLAB gives me a warning as following:
Warning: Error updating Text.
Character vector must have valid interpreter syntax:
$\Theta(s) = 9.24\cdot 10^{04 }\cdot \frac{s + 0}{s^{4} + 140s^{3} + 2.35\cdot 10^{03s}^{2} + 9.24\cdot 10^{04s} + 0}$
I'm not sure why it is invalid syntax. I'm using the following code:
numericTF = struct;
symbolTF = struct;
if strcmp(vars.response_type,'Position')
typeString = 'Theta(s)';
else
typeString = 'Omega(s)';
end
tf4thOnum = [1 I/P];
tf4thOden = [1 (b*L+R*J)/J/L (R*b+ Kb*Km)/J/L 2*Km*P/J/L I*2*Km/J/L];
tf4thOgain = 2*Km*P/J/L;
tf4thOstr = sprintf('$\\%s = %4.3g \\cdot \\frac{s + %4.3g}{s^{4} + %4.3gs^{3} + %4.3gs^{2} + %4.3gs + %4.3g}$', typeString, tf4thOgain,tf4thOnum(2:end),tf4thOden(2:end));
tf4thOsym = '\frac{k_ak_mk_p}{JL}\cdot\frac{s+\frac{k_i}{k_p}}{s^4+\frac{bL+RJ}{JL}s^3+\frac{bR+k_bk_m}{JL}s^2+\frac{k_ak_mk_p}{JL}s+\frac{k_ik_mk_ap}{JL}}$';
Another function to add scientific notation:
function instring = cleanExps(instring)
exps = findstr(instring,'e+');
maxn = length(exps);
if ~isempty(exps)
for ii = 1:maxn
if isempty(exps) break; end
instring = strrep(instring,instring(exps(1):exps(1)+4),['\cdot 10^{' instring(exps(1)+2:exps(1)+4) '}']);
exps = findstr(instring,'e+');
end
end
exps = findstr(instring,'e-');
maxn = length(exps);
if ~isempty(exps)
for ii = 1:maxn
if isempty(exps) break; end
instring = strrep(instring,instring(exps(1):exps(1)+4),['\cdot 10^{-' instring(exps(1)+2:exps(1)+4) '}']);
exps = findstr(instring,'e-');
end
end