Why won't "bar" graphing function work?

I am trying to learn MATLAB through examples. When I try bar(y), using examples posted in help documentation I get the following errors:
y = [75.995,91.972,105.711,123.203,131.669,...
150.697,179.323,203.212,226.505,249.633,281.422];
>> figure; bar(y);
??? Index exceeds matrix dimensions.
Error in ==> bar at 95
set(listeners(2),'enable','off');

回答 (2 件)

Walter Roberson
Walter Roberson 2012 年 10 月 8 日

0 投票

Often when something like that happens, it is due to the user having accidentally created a .m file that is the same name as a function used internally.
Which MATLAB release are you using, on which OS?
Wayne King
Wayne King 2012 年 10 月 8 日

0 投票

y = [75.995,91.972,105.711,123.203,131.669,...
150.697,179.323,203.212,226.505,249.633,281.422];
figure
bar(y)
Should work fine, are you sure this is the only code you're executing for this example?

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

質問済み:

2012 年 10 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by