How to convert long to scientific e format in plots legend?

5 Ansichten (letzte 30 Tage)
Kalasagarreddi Kottakota
Kalasagarreddi Kottakota am 10 Jun. 2022
Kommentiert: Bjorn Gustavsson am 10 Jun. 2022
txt = ['lambda = ',num2str(lambda(check))];
plot(1:100, abs(Arec(:,2000)),'DisplayName',txt)% capon
legend show
How to change the long format to scieitific e, like 1e6 in legend?

Antworten (1)

Bjorn Gustavsson
Bjorn Gustavsson am 10 Jun. 2022
You could be a bit more explicit in the call to legend:
txt = ['lambda = ',num2str(lambda(check))];
ph = plot(1:100, abs(Arec(:,2000))); % ,'DisplayName',txt); % capon
leg_str = sprintf('lambda = %3.3g',lambda(check));
  2 Kommentare
Bjorn Gustavsson
Bjorn Gustavsson am 10 Jun. 2022
True, but explicitly calling legend with the plot-handles has additional benefits in terms of what to include, which is not necessary in this case but will eventually pop up.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by