Can I acess value of variable in legend of plot
21 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
venkat siddhartha rama
am 22 Jul. 2019
Kommentiert: Charaf-ed-dine EL FATTAHI
am 15 Feb. 2022
Hi, I have a plot for which I need to have the integrated values next to each legend. I mean, Can I use %0.2f which is used in fprintf statement to get the value of the variable used. Below is the code line of the legend, Hopefully I have explained it well enough..
% Code Line Begins here%
legend('Only Solar Generation[Integrated = %0.2f KW]','Only Wind Generation[Integrated = %0.2f KW]' ,'Load of community[Integrated = %0.2f KW]','Combined wind and solar power produced[Integrated = %0.2f KW]', 'Excess Energy Produced[Integrated = %0.2f KW]','Defecit Energy[Integrated = %0.2f KW]', Integrated_Just_solar_Farm_generation,Integrated_hourly_wind_power1,Integrated_Community_Hourly_load_demand,Integrated_comined_wind_and_solar_power,Integrated_Excess_energy_produced,Integrated_Defecit_Energy );
%Code line Ends here%
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 23 Jul. 2019
I would make up each legend using sprintf, then call legend
legend1 = sprintf('Only Solar Generation[Integrated = %0.2f KW]', num1);
legend2 = sprintf('Whatever...%f', num2);
legend3 = sprintf('Whatever...%.1f', num3);
legend(legend1, legend2, legend3);
It's a lot simpler this way.
2 Kommentare
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!