Error using bar (line 172) X must be same length as Y.

2 次查看(过去 30 天)
i am trying to plot a bar graph as illustrated in https://nl.mathworks.com/help/matlab/ref/bar.html
with the example code:
x = 1990;
y = [10 20 30];
bar(x,y)
but I got the error as menitioned in the Title.
is there any solution for it?
  3 个评论
Tim Boxall
Tim Boxall 2021-3-12
Same for me, using R2017b. I copied the example code exactly and got the same error.
hicham oufettoul
hicham oufettoul 2022-3-19
Hi dear brother I hope you find the answer, if yes let me know it please, and thank you

请先登录,再进行评论。

回答(1 个)

Stephan
Stephan 2020-8-17
Transpose y:
x = 1990;
y = [10 20 30]';
bar(x,y)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by