【问题标题】:How to draw Bar Chart from Excel File in Matlab? [closed]如何在 Matlab 中从 Excel 文件中绘制条形图? [关闭]
【发布时间】:2013-12-30 21:29:41
【问题描述】:

我是 Matlab 的新手。假设我在 excel 中有一个表,passenger.xls,如下所示:

Id  StaName   In  Out 

1   StationA  10  80

2   StationB  50  40

3   StationC  25  45

如何在 Matlab 中制作适当的条形图,如上表所示,以 StationName 显示 InOut

请给我一个分步说明来完成这项任务吗?非常感谢您的帮助。

【问题讨论】:

    标签: excel matlab bar-chart


    【解决方案1】:
    % A very simple example that does not attempt any checks on the input data.
    
    % Load your Excel file into MatLab.
    % Replace YourExcelFile with the correct file name
    [numeric,textual,raw]=xlsread('YourExcelFile');
    
    % Assuming that the example data starts in cell A1 and is of the format
    % shown, plot the 'In' and 'Out' numeric data in a bar graph.
    bar(numeric(1:end,3:end));
    
    % Replace the numeric labels on the x axis with the values from StaName.
    % Do this by setting the XTickLabel property on the current graph axis.
    set(gca,'XTickLabel',textual(2:end,2));
    

    【讨论】:

    • 太棒了,它真的有效!!非常感谢你,你真的很有帮助。如果你不介意,我还有一个问题。如果我想反转条形图,现在 Y 轴是 StationName 而 X 轴是 In 和 Out,这样做的命令是什么?我尝试了一些,但没有奏效。谢谢。
    • 好的,我用 barh 找到了它。谢谢...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-27
    • 1970-01-01
    • 1970-01-01
    • 2014-08-22
    相关资源
    最近更新 更多