在MATLAB中绘制条形图

编程入门 行业动态 更新时间:2024-10-26 05:18:01
本文介绍了在MATLAB中绘制条形图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在MATLAB中有一个矩阵(4,100)。其列中的每一列都是这样的:第一元素矩阵(1,i)越小,第四元素矩阵(4,i)越大。就像

matrix(:,1)= - 0.3; 0,4; 0,4; 0,9

我怎样才能做一个条形图?两条边??

每栏必须以栏为单位表示,以便在最后制作100栏。

感谢

解决方案

我不确定这是否是您想要的,但您可以绘制所有不同颜色的酒吧,从最大(最后一行矩阵)到最小的(矩阵的第一行),以便更小的堆积过来,但让更大的看到:

matrix = [.1.2 .3 .4 .5 .2 .3 .5 .6 .7 .4 .8 .7 .8 .5 .6 .9 .8 .9 .9]; %//示例数据持有颜色= {'r','g','b','c'}; %//定义颜色对于n = size(矩阵,1): - 1:1%//遍历行,从最后到第一个 bar(matrix(n,:),colors {n }) end

I have a matrix(4,100) in MATLAB. Each one of its column are in such way that the 1st element matrix(1,i) is the smaller and the 4th element matrix(4,i) is the bigger. Something like

matrix(:,1) = - 0.3; 0,4; 0,4; 0,9

How can I do a bar graph were I can plot as a bar the distance between the two edges?

each column has to be represented by on bar in order to make 100 bars at the end.

Thanks

解决方案

I'm not sure if this is what you want, but you can plot all bars in different colors, from the largest (last row of matrix) to the smallest (first row of matrix), so that the smaller ones get stacked over but let the larger ones to be seen:

matrix = [.1 .2 .3 .4 .5 .2 .3 .5 .6 .7 .4 .4 .8 .7 .8 .5 .6 .9 .8 .9]; %// example data hold on colors = {'r','g','b','c'}; %// define colors for n = size(matrix,1):-1:1 %// iterate over rows, from last to first bar(matrix(n,:), colors{n}) end

更多推荐

在MATLAB中绘制条形图

本文发布于:2023-07-18 00:47:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1139243.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:条形图   MATLAB

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!