matlab程序甘特图
时间: 2023-09-12 17:03:57 浏览: 103
你可以使用以下的MATLAB程序来生成甘特图。
```matlab
startT = [0 3 5 12 16,1.5 6 8 15 18,3 10 11 16 19,2 4 11 13 15,1 3 7 16 18,5 11 14 16 20];
durationT = [3 2 5 4 4,4 1 7 2 5,6 1 4 3 2,1 6 2 2 9,2 3 4 2 5,5 3 1 2 8];
jobId = [1 1 1 1 1,2 2 2 2 2,3 3 3 3 3,4 4 4 4 4,5 5 5 5 5,6 6 6 6 6];
GTC = ganttChart(startT,durationT,jobId);
colorList = [204,154,129;222,191,170;185,184,163;165,165,139;107,112,92]./255;
for i = 1:max(jobId)
tHdl = GTC.(['p',num2str(i)]);
for j = 1:length(tHdl)
set(tHdl(j),'FaceColor',colorList(j,:))
end
end
ax = gca;
ax.YTickLabel = {'S-1-1','S-1-2','S-2-1','S-2-2','S-3-1','S-3-2'};
```
这段程序中,`startT`表示每个任务的开始时间,`durationT`表示每个任务的持续时间,`jobId`表示每个任务的编号。首先,使用`ganttChart`函数生成一个初始的甘特图对象。然后,使用循环为每个任务修改颜色,根据`jobId`选择对应的颜色。最后,通过设置`ax.YTickLabel`来修改y轴刻度标签为对应的任务标识。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [基于遗传算法的车间调度算法-matlab源码(含甘特图)](https://download.csdn.net/download/m0_59415345/85425314)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [MATLAB | 如何使用MATLAB绘制甘特图(gantt chart)](https://blog.csdn.net/slandarer/article/details/127469719)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文