Error plotting a bar graph because Assigning to 2 elements using a simple assignment statement is not supported.
Ältere Kommentare anzeigen
Dear Mathcoders,
I have been striving with this code, but I don find the way to make it without producing this error, I have followed the indications of MATLAB and I used "deal" to make the comma list separated, however It still send me the same error. Do you mind giving me any insights to overcome this issue?
"Assigning to 2 elements using a simple assignment statement is not supported. Consider using comma-separated list
assignment.
Error in PGeo__SCy (line 383)
b2.BarWidth = 0.4;"
figure(1)
n=12;
U1=[energy_, (heat_cons + HDW_c)]; %%%Renewable generation
U2=[(Power_ + Sp_ + Lamp_), (heat_cons_ + HDW_c)*SPF]; %%%Consumption
c{1}=deal(U1); %%%Renewable generation
c{2}=deal(U2); %%%Consumption
b1= bar(c{1},'stacked');
b1(1).BarWidth = 0.4;
hold on;
b2=bar(c{2},'stacked');
b2.BarWidth = 0.4;
b2.XData = (1:n) - 0.5; % move bars left
xlabel('Months', 'FontWeight','bold')
ylabel('Consumption vs RES (kWp)', 'FontWeight','bold')
grid on
xticklabels(LastName)
% go.Annotation.LegendInformation.IconDisplayStyle = 'on';
labels = {'Electricity consumption' 'Thermal consumption' 'Photovoltaic Generation' 'Geothermal Generation' };
legend([b2 b1], labels);
%
% saveas(gcf,'_EnergyShare.png')
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!