bar chart for an array

8 次查看(过去 30 天)
I'm trying to create a bar chart for a matrix, its a 1x30 but I only want the 0, 10th, 20th and 30th values.
I've tried many formats such as in the image but I cannot manage to get it working.
Any suggestions out there?

采纳的回答

Ameer Hamza
Ameer Hamza 2018-5-4
编辑:Ameer Hamza 2018-5-4
I MATLAB, use the following syntax to index into an array.
bar([1 10 20 30], mean_1_1_walk([1 10 20 30]))
Also in MATLAB indexing start from 1, unlike some other programming languages (such as c/c++, java, python) where indexing starts from 0.
  8 个评论
Jordanf1519
Jordanf1519 2018-5-5
Would anyone know how to change the colours of these bars too?
bar([1 10 20 30], [mean_1_1_walk([1 10 20 30])' mean_1_2_walk([1 10 20 30])']);
Ameer Hamza
Ameer Hamza 2018-5-5
You can find several examples on documentation page which will help you to do this: https://www.mathworks.com/help/matlab/ref/bar.html#d119e66370.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Bar Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by