To plot a bar graph with 10 items and x and y labels in Matlab, follow these steps:
Define a vector with the data to be plotted. For example:
main.m30 chars2 lines
Use the bar
function to create the bar graph:
main.m11 chars2 lines
Use the xlabel
function to add a label to the x-axis of the graph:
main.m23 chars2 lines
Use the ylabel
function to add a label to the y-axis of the graph:
main.m17 chars2 lines
(Optional) Use the title
function to add a title to the graph:
main.m23 chars2 lines
Here's the complete code:
main.m104 chars6 lines
This will create a bar graph with 10 items, labeled on the x-axis from 1 to 10, and with the values of the data vector plotted on the y-axis.
gistlibby LogSnag