How to use bar() to plot
3 ビュー (過去 30 日間)
古いコメントを表示
%% Task 3 - PLOT
figure(1)
subplot(2, 2, 1)
plot(avgCO2, Time2);
subplot(2, 2, 2)
plot(avgTA, Time1);
subplot(2, 2, 3)
bar(prct_inc, Time2);
subplot(2, 2, 4)
plot(avgTA, avgCO2)
Error using bar (line 182)
XData values must be unique.
Error (line 52)
bar(prct_inc, Time2);
How do I fix this?
0 件のコメント
採用された回答
William
2021 年 1 月 10 日
I suspect the arguments to your plot() functions are reversed, When you type plot(a,b), Matlab puts 'a' on the x-axis ahd 'b' on the y axis. So, when you write 'plot(avgCO2, Time2);', it is going to put time on the vertical axis and avgCO2 on the horizontal axis. That's probably the opposite of what you wanted.
When it got to the bar-graph bar(prct_inc, Time2), it used prct_inc as the independent variable (the x-axis) and apparently found two or more values that were identical, which is not allowed in a bar-graph. If Time2 were plotted on the x-axis using bar(Time2,prct_inc), this probably wouldn't happen since you wouldn't normally have two identical values of time.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!