Can I acess value of variable in legend of plot

35 ビュー (過去 30 日間)
venkat siddhartha rama
venkat siddhartha rama 2019 年 7 月 22 日
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%

採用された回答

Image Analyst
Image Analyst 2019 年 7 月 23 日
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 件のコメント
venkat siddhartha rama
venkat siddhartha rama 2019 年 7 月 24 日
Thanks, it Works...
Charaf-ed-dine EL FATTAHI
Charaf-ed-dine EL FATTAHI 2022 年 2 月 15 日
Sir, you are a legend!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by