✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab完整代码及仿真定制内容点击👇
🔥 内容介绍
甘特图在几个关键方面与其他图表不同:
关注时间:甘特图主要关注时间。它们显示任务的开始和结束日期及其持续时间。这使它们成为项目规划和调度的理想选择。
任务依赖性:甘特图也可用于显示任务依赖性。这显示了不同的任务如何相互关联以及它们需要如何按顺序完成。这可以帮助识别潜在的瓶颈并确保项目按时完成。
进度跟踪:甘特图也可用于跟踪项目的进度。这可以通过在任务完成时更新任务的开始日期和结束日期来完成。这有助于及早发现任何潜在问题并根据需要进行调整。
其他类型的图表,例如条形图、折线图和饼图,并不是专门为项目规划和调度而设计的。它们可用于以多种方式可视化数据,但它们不显示任务依赖性或进度跟踪。
📣 代码
%% Gantt Chart in MATLABclc,clear all,close all,tasks = {'Task 1', 'Task 2', 'Task 3'};start_times = [1, 4, 7]; % Start times in daysend_times = [3, 6, 9]; % End times in daysdurations = end_times - start_times;figure;bar(start_times, durations, 'stacked');% Add task labelstask_labels = strcat(tasks, ' (', num2str(durations), ' days)');yticks(start_times + durations / 2);yticklabels(task_labels);% Set axis labelsxlabel('Time (days)');ylabel('Tasks');title('Gantt Chart');grid on;%figure;% show;%%% clear all,close all,clc,% Define your tasks and their start and end timestasks = {'Task 1', 'Task 2', 'Task 3'};start_times = [1, 4, 7]; % Start times in daysend_times = [3, 6, 9]; % End times in days% Calculate the duration of each taskdurations = end_times - start_times;% Define colors for each taskcolors = {'red', 'yellow', 'blue'};% Create the Gantt chartfigure;% Specify the time scale (you can change this as needed)time_scale = 1; % In days, adjust as necessary% Create a bar chart with specified colorsfor i = 1:length(tasks)barh(i, durations(i) * time_scale, 'FaceColor', colors{i});hold on;end% Customize the Gantt chart appearanceyticks(1:length(tasks));yticklabels(tasks);xlabel('Time (days)');ylabel('Tasks');title('Customized Gantt Chart');grid on;xlim([0, max(end_times) * time_scale + 2]); % Adjust the x-axis limit as needed% Show the Gantt chart% show;
⛳️ 运行结果

3568

被折叠的 条评论
为什么被折叠?



