How do I draw barh using both axes values?
2 次查看(过去 30 天)
显示 更早的评论
Hi All
How do I draw barh ( horizontal bars) taking into consideration both axes values : saying when 0<x<100 , draw a bar between 10<y<12
采纳的回答
Walter Roberson
2020-4-28
x_to_draw_at = x(0 < x & x < 100);
bar(x_to_draw_at, 12*ones(1,length(x_to_draw_at)), 'basevalue', 10)
4 个评论
Walter Roberson
2020-4-28
For values of ranges, by definition ranges <= max(ranges). When ranges is entirely positive, then max(ranges) is positive and max(ranges)*1.1 is even larger than max(ranges) so you can be sure that ranges < max(ranges)*1.1 .
So when could ranges < max(ranges)*1.1 be false?
- max(ranges) is 0, in which case 0*1.1 is 0, and 0 < 0 is false. On the other hand, the case of 0 is already eliminated by 0 < ranges
- max(ranges) is negative, in which case max(ranges)*1.1 is more negative, and it could be the case that there are some values that are more negative than max(ranges) but not as negative as max(ranges)*1.1. For example, -10.5 and -10, max() is -10, max()*1.1 is -11, and -10.5 < -11 is false. However, this can only happen for negative values, never for positive values, and you already eliminate negative values with 0 < ranges .
You should reconsider your test. Perhaps you want something like max(ranges)*0.9
by the way , the bars should be horizontal. does the code do this ?
You are going to need to describe what the output should look like: we as outsiders need to assume that the x values are not sorted and not continuous.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!