同学代码供参考:
clc;clear
st = [0,100;
0, 105;
0, 98;
0, 110;
680, 720;
540, 590;
];
device_id = [
1;2;3;4;11;12
];
labels = {
'7-1';'4-1';'2-1';'6-1';'8-3';'4-3'
};
figure(1);clf
for i = 1:size(st,1)
gant(st(i,1), st(i,2), device_id(i), labels{i})
end
set(gca, 'fontsize', 12, 'fontname', 'times new roman')
set(gca, 'ytick',1:13,'yticklabel', cell(size(1:13)))
yticks = arrayfun(@(i)['M',num2str(i)],1:12,'uniform',0);
arrayfun(@(i)text(0-(max(st(:,2))+min(st(:,1)))/20,i-0.5,yticks{i},'HorizontalAlignment','center',...
'VerticalAlignment','mid','fontsize',14,'fontname','times new roman'), 1:numel(yticks))
axis([0 800 0 12.5])
grid('on')
效果:
有帮助望采纳哟