Info
此问题已关闭。 请重新打开它进行编辑或回答。
How to obtain all the bar graphs. My code only gives one bar graph even though I have written a code to get four bar graphs.
1 次查看(过去 30 天)
显示 更早的评论
I have to plot four different bar graphs, and for each I am forming a matrix and then subsequently plotting it. The output shows only one bar graph, the other three are missing. Below is a picture of that portion of the code.
It's showing bar graph only for the last matrix, i.e., the one for which code lines 368 to 375 are dedicated.
I want all the bar graphs to come out as different figures in the output. Please help.
0 个评论
回答(1 个)
Gaurav Garg
2019-11-18
Hi,
bar(y) creates a bar graph with one bar for each element in y. In your case, you plot the bars on top of each other and hence, you see the bar graph only for the last matrix/data.
So, you can choose to append the matrices in a single matrix and plot bar for the resultant matrix.
An example -
y1=[1:4];
y2=[5:8];
y3=[9:12];
x=[1:4];
bar(x,[y1;y2;y3]');
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!