binning the x-axis of a plot

I need to create bins for the x-axis of my plot. The axis goes from 0 to 20, and I need to make bins corresponding to every .10 of a value; i.e. 5.0 to 5.10. How would I go about doing this?

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 2 月 9 日

0 投票

xbins = 0 : 0.10 : 20;

4 件のコメント

jgillis16
jgillis16 2016 年 2 月 9 日
how would I include this bin within my plot?
Trying to bin the plot that uses the variables: r = 1027; txx2 = 1027; xbins = 201;
plot(r,txx2,xbins)
error because xbins is not a consistent size with r and txx2
Walter Roberson
Walter Roberson 2016 年 2 月 9 日
Include it in what sense? Do you want each point labeled with its bin number? Do you want a second x axis that is labeled with bin numbers?
jgillis16
jgillis16 2016 年 2 月 9 日
I want the x-axis to be binned. So instead of going from 0 to 20, it should go from 0, 0.10, 0.20, etc. Would that be possible? The only thing that's worrying is the matrix sizes are not consistent.
Or, a second axis could work too
Walter Roberson
Walter Roberson 2016 年 2 月 9 日
xbins = 0 : 0.10 : 20;
plot(r,txx2);
set(gca, 'xtick', xbins)
But what I suspect you want is something closer to
bar(r, txx2)

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

質問済み:

2016 年 2 月 9 日

コメント済み:

2016 年 2 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by