You can refer to the attached Simulink model for reference and suitably modify the model to solve your problem.
The attached model provides functionality to use the temperature data from the timeseries object as input to the Simulink model.
The data required for the model to work is created in the MATLAB's base workspace using the ‘InitFcn’ model callback. You can access and modify the ‘InitFcn’ callback from the model properties.
The following code is executed in the ‘InitFcn’ callback function:
load outdoors;
outdoors.Properties
rowsInTimeTable = numel(outdoors.Properties.RowTimes);
timeData = outdoors.Time(:);
temperatureData = outdoors.TemperatureF(:);
startTime = datetime(timeData(1));
timeInHrMinSec = timeData - startTime;
timeInSeconds = seconds(timeInHrMinSec);
t = timeInSeconds;
tempData = temperatureData;
stopTime = t(rowsInTimeTable);
You will need to make the following changes to the model:
- In Model Configuration Parameters (Press CTRL+E to open), under Data Import/Export settings, Check the box against input under the Load from Workspace option. Enter the input as [ t, tempData] where “t” is a column vector of time (in seconds) and "tempData" is a column vector of temperature data. This data will get loaded from the workspace. The variable tempData corresponds to the input port 1.
- In Solver options, make the following changes:
- Change the solver to Fixed-step auto solver.
- Change the step-size to 5400 seconds (In your case, this will be 300 seconds as your data gets updated every 5 minutes)