bar chart for an array
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
0 投票
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
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 件のコメント
dpb
2018 年 5 月 4 日
"... unlike most other programming languages."
"... unlike one other particular programming language."
Jordanf1519
2018 年 5 月 4 日
That sorted it, thank you.
dpb
2018 年 5 月 4 日
Also note you can write expressions like
mean_1_1_walk([1:10:end])
besides a list of specific indices.
Jordanf1519
2018 年 5 月 4 日
Ameer Hamza
2018 年 5 月 4 日
@dpb OP is indexing them like [1 10 20 30] for some reason. Therefore I wrote it like that.
bar([1 10 20 30], [mean_1_1_walk([1 10 20 30])' mean_1_2_walk([1 10 20 30])']);
dpb
2018 年 5 月 4 日
Indeed he did, but he also started counting from 0 instead of 1. It's quite possible he didn't know could write an expression; was simply giving alternate syntax as tutorial additional information.
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
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 件)
カテゴリ
ヘルプ センター および File Exchange で Bar Plots についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
