How to generate entities where the inter-arrival times are specified from a Spreadsheet (Simulink)

4 次查看(过去 30 天)
I ran the example, Inter-Arrival Times from Sequence and Initialize from Spreadsheet from Generating and Initializing Entities - MATLAB & Simulink (mathworks.com)
My goal is to generate entities where the inter-arrival times are specified from a Spreadsheet. But this example generates entities from the array [1.5 1.0 0.5 0.3 1.2] specified in getNextFromSequence function.
The Scope result shows the interarrival time specified in the array, because Entity Generator ('Customer') lists 'dt = getNextFromSequence();'.
Q1: How do I modify this example to generate entities where the interarrival times are specified from my own spreadsheet (e.g., 'interarrivaltime' column)? I have to read the measured interarrival times from a spreadsheet.
Q2: The wep page says "Initialize the generated entities using data from a spreadsheet by importing the data to a MATLAB table object." What does 'Initialize' mean in this context?
Q3: In general, service times are specified in the Entity Server, but not needed in the Entity Generator (arrival times). The function initFromSpreadsheet() has 'svctime' ArgOut. What does 'svctime' in the .xlsx do for the Entity Generator ('Customer')? FYI, eventually I will add the Entity Queue and Entity Server to make a single server single queue.
>> tableData = readtable('seExampleSpreadsheetData.xlsx')
tableData =
10×3 table
id priority svctime
__ ________ _______
1 10 1.5
2 9 2
3 8 0.5
4 7 1
5 6 1.5
6 5 2
7 4 0.5
8 3 1
9 2 1.5
10 1 2
In advance, thanks for your help.

采纳的回答

Kirsten Hart
Kirsten Hart 2022-9-23
Q1: This example has a spreadsheet file named ‘seExamplesSpreadsheetData.xlsx’ with columns ‘id’ and ‘svctime’. To specify your own spreadsheet, you can change the file name in the ‘readtable function that is in the ‘PreLoadFcn’ callback. To navigate to the ‘PreLoadFcn’ callback, go to the ‘Modeling’ tab in the Simulink toolstrip, click ‘Model Settings’ dropdown, select ‘Model Properties’, go to the ‘Callbacks’ tab of the ‘Model Properties’ window, select ‘PreLoadFcn’ on the lefthand side of the window.
Please refer to the following MathWorks documentation page for more information on model callback parameters: https://www.mathworks.com/help/releases/R2020a/simulink/ug/model-callbacks.html#btoznm0
Q2: Initializing the generated entities using data from a spreadsheet by importing the data to a MATLAB table object means to assign a MATLAB table object to the data in a spreadsheet. You can do that with the readtable’ function like from the example (pasted below):
>> tableData = readtable(‘seExampleSpreadsheetData.xlsx’)
The ‘readtable’ function creates a MATLAB table object from the specified file. Please refer to the following MathWorks documentation page for more information on the ‘readtable’ function: https://www.mathworks.com/help/releases/R2020a/matlab/ref/readtable.html/
Q3: The function ‘initFromSpreadsheet()’ has ‘svctime’ as an output argument because every entity has an ‘ID’ and a ‘ServiceTime’. In this specific example, the service time is not used since there is no Entity Server attached to it. However, the service time data needs to be there in order to properly construct the entities.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Messages 的更多信息

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by