The bar command draws a two dimensional bar chart. Let us take up an example to demonstrate the idea.
Example
Let us have an imaginary classroom with 10 students. We know the percent of marks obtained by these students are 75, 58, 90, 87, 50, 85, 92, 75, 60 and 95. We will draw the bar chart for this data.
MATLAB provides eight basic color options for drawing graphs. The following table shows the colors and their codes:
w- White k - Black b - Blue r - Red c - Cyan g - Green m - Magenta y - Yellow
Example
Plot three sine curves with a small phase shift between each line. Use a green line with no markers for the first sine curve. Use a blue dashed line with circle markers for the second sine curve. Use only cyan star markers for the third sine curve.
Create a script file and type the following code into it:
str1 = 'This is test' str2 = 'This is text' if (strcmp(str1, str2)) sprintf('%s and %s are equal', str1, str2) else sprintf('%s and %s are not equal', str1, str2) end
When you run the file, it displays the following result:
str1 = This is test str2 = This is text ans = This is test and This is text are not equal