figure('Name','frequency of reduced category response by groups');
h = bar(mean_resp_bygroup([3,4,2,1],:)); %mean_resp_bygroup is a 4-by-2 double matrix
h.YLabel = 'Reduced Category Response';
h.DisplayName = {'OR','XOR'}; %legend labels
h.XTickLabels = {'W','X','Y','Z'};
legend();
title('Frequency of Reduced category response');
I get this error message: Expected one output from a curly brace or dot indexing expression, but there were 2 results.
I suspect that has something to do with how the function bar works in the background. Anyone has any idea how to solve this issue?

4 Kommentare

jonas
jonas am 6 Jul. 2020
What line is the error referring to?
Mingjia Hu
Mingjia Hu am 6 Jul. 2020
h.YLabel = 'Reduced Category Response'
jonas
jonas am 6 Jul. 2020
then I suspect that is where the error is ;)
Mingjia Hu
Mingjia Hu am 6 Jul. 2020
Now I get this error:
Error setting property 'YLabel' of class 'Axes':
Value must be 'matlab.graphics.Graphics'.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 6 Jul. 2020
Bearbeitet: Fangjun Jiang am 6 Jul. 2020

0 Stimmen

because your data is 4x2, h is an 1x2 array so you can't use h.YLabel. Check the value of h
You have to use h(1).YLabel but then 'YLabel' is not a valid property

6 Kommentare

Mingjia Hu
Mingjia Hu am 6 Jul. 2020
Then how can I add a Y label for the whole figure?
ax = gca;
ax.YLabel = 'blabla'
Mingjia Hu
Mingjia Hu am 6 Jul. 2020
Now I get this error:
Error setting property 'YLabel' of class 'Axes':
Value must be 'matlab.graphics.Graphics'.
'YLabel' is a property of the axes.
f=figure;
a=axes;
h=bar(rand(4,2));
a.YLabel.String='Reduced Category Response'
legend({'OR','XOR'})
jonas
jonas am 6 Jul. 2020
Sorry, I always forget the .String field :)
Mingjia Hu
Mingjia Hu am 6 Jul. 2020
Thank you guys. Problem solved!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Discrete Data Plots finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by