我是Matlab的新手。假设我在excel,passenger.xls中有一个表,如下所示:
Id StaName In Out
1 StationA 10 80
2 StationB 50 40
3 StationC 25 45
如何在Matlab中制作一个合适的条形图,按照In
显示Out
和StationName
,如上表所示?
请你给我一步一步的指示来完成这项任务吗?非常感谢你的帮助。
答案 0 :(得分:3)
% 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));