How do I put variable values into a text string for Legend
41 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hamid Reza Barzegar
am 5 Feb. 2017
Kommentiert: Star Strider
am 5 Feb. 2017
I want to put the variable as a legend but in form of power of some amount this is the variable
x=-1.1;
then in the result i want to see 10^-1.1
figure
plot(Ratio,Final_1,'k-x','linewidth',2)
grid on
legendInfo = ['SNR target for BER 10^' num2str(x)];
legend(legendInfo,'Location','southeast')
xlabel('Ratio')
ylabel('SNR')
problem i have is this part "'SNR target for BER 10^' num2str(x)" because it is not showing like 10^x
0 Kommentare
Akzeptierte Antwort
Star Strider
am 5 Feb. 2017
Use the sprintf function:
legendInfo = sprintf('SNR target for BER 10^%f', x);
5 Kommentare
Star Strider
am 5 Feb. 2017
My pleasure.
I thought you wanted integers rounded to the next lowest integer. The '%.1f' is the correct option for one decimal-place floating-point precision.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Legend finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!