Latex, sprintf and variable that changes
Mostrar comentarios más antiguos
Hello everyone,
In the following MATLAB code snippet:
title(sprintf('\\textbf{Product of $\\phi$ with %0.2f delayed $\\phi(t-\\%%0.2f)$ and a = %0.1f}', k(j).*T , a(i)),'Interpreter','latex');
The objective is to create a plot title combining LaTeX formatting with the value of k(j)*T. However, there seems to be an issue with the rendering of the term $\phi(t-\%0.2f)$.
What could be causing the issue in the LaTeX expression, and how can it be fixed to combine LaTeX formatting with the value of k(j)*T effectively?
Thanks in advance
The complete code:
T=1/100;
over=100;
Ts=T/over;
A=4;
a=[0,0.5,1];
k=[0,1,2];
for i=1:length(a)
[phi, t] = srrc_pulse(T,over,A,a(i));
for j=1:length(k)
figure(6*(i-1) + 2*(j-1) + 1);
hold on;
%subplot(2,1,1);
plot(t,phi);
hold on;
title(sprintf('Pulses with a = %0.1f', a(i)));
%subplot(2,1,2);
tdelayed = t+(k(j).*T);
plot(tdelayed,phi);
legend('Original \phi',sprintf('delay %0.2f', k(j).*T));
hold on;
grid on;
% Save the images
filename_subplot = sprintf('subplotWithA=%d_K=%d.png', a(i), k(j));
saveas(gcf, filename_subplot);
phioriginal = [phi zeros(1,k(j)*T/Ts)];
phidelayed = [zeros(1,k(j)*T/Ts) phi];
tmultiplication = [t(1):Ts:t(end)+k(j)*T];
figure(6*(i-1) + 2*(j));
plot(tmultiplication,phioriginal.*phidelayed);
title(sprintf('\\textbf{Product of $\\phi$ with %0.2f delayed $\\phi(t-\\%%0.2f)$ and a = %0.1f}', k(j).*T , a(i)),'Interpreter','latex');
grid on;
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Annotations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



