Not enough input arguments when using bar()
Ältere Kommentare anzeigen
Hi,
I am trying to generate a bar graph specifically 'Specify Bar Locations as String Vector' from the documentation.
x = ["Outdoor1" "Outdoor2" "Outdoor3" "Outdoor4"];
y = [540 524 515 424];
>> bar(x,y)
Error using bar
Not enough input arguments.
I am not able to figure out why am I getting the above error when the example mentioned in the documentation is pretty much the same but seems to be working.
2 Kommentare
Maybe you have a function called bar in your current folder?
which bar
Raghav Rathi
am 20 Sep. 2023
Akzeptierte Antwort
Weitere Antworten (1)
Dyuman Joshi
am 20 Sep. 2023
Bearbeitet: Dyuman Joshi
am 20 Sep. 2023
It works fine here - R2023b but does not on my MATLAB app - R2021a.
Since you have R2023a, it means that the support for string array as input to bar must have been implemented in R2023b.
Workaround > Convert x to a categorical array and then plot -
x = ["Outdoor1" "Outdoor2" "Outdoor3" "Outdoor4"];
x = categorical(x);
y = [540 524 515 424];
bar(x,y)
1 Kommentar
Raghav Rathi
am 20 Sep. 2023
Kategorien
Mehr zu Annotations 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!


