An object for a custom class can be created and its corresponding method can be called within the MATLAB action section of the entity generator. Below is a sample definition of a TaskList class to illustrate this approach:
classdef TaskList
properties
% Example property to store task start times
taskStartTimes
currentIndex
end
methods
function obj = TaskList()
% Constructor to initialize the task list
% Example: Initialize with some dummy start times
obj.taskStartTimes = [0.1,0.2,0.3,0.4,0.5]; % Example start times
obj.currentIndex = 1; % Start at the first task
end
function [obj, dt] = getNextStart(obj)
% Method to get the next start time delta
if obj.currentIndex <= length(obj.taskStartTimes)
dt = obj.taskStartTimes(obj.currentIndex);
obj.currentIndex = obj.currentIndex + 1; % Move to the next task
else
dt = inf; % No more tasks, return infinity or some sentinel value
end
end
end
end
The getNextStart method provides the interval for the next entity generation. In the entity generator, set the Generation method to Time-Based and the Time source to MATLAB action. This enables the Intergeneration time action section, where the following code can be used to create a persistent TaskList object and call the getNextStart method:
persistent task_list;
if isempty(task_list)
% Initialize your task_list object here
task_list = TaskList(); % Assuming TaskList is your class
end
[task_list, dt] = task_list.getNextStart();
With this setup, the entity intergeneration times will correspond to the values specified in the taskStartTimes array.

For further information, the Specify Intergeneration Times for Entities documentation page can be accessed using the command below:
web(fullfile(docroot, 'simevents/ug/specifying-intergeneration-times-for-entities.html'))
