Why do I receive an error when using eventForward?

13 Ansichten (letzte 30 Tage)
Lam An
Lam An am 11 Jun. 2024
Verschoben: Walter Roberson am 11 Jun. 2024
I just started writing a new custom matlab.DiscreteEventSystem block, and for some reason, I keep getting the following error when it compiles:
Simulink detected an error
'Dimension 1 of field 'type' is fixed on the left-hand side but varies on the right ([1 x 0] ~= [:? x :?]).'.
The error occurred for MATLAB System block 'shawmutSim_v5/MATLAB Discrete-Event System'. See line 118, column 13 in file '/Applications/MATLAB_R2024a.app/toolbox/slde/slde/+matlab/DiscreteEventSystem.m'. The error was detected during code generation phase.
Start code generation report.
Upon investigation, it seems to be complaining about the last line in the eventForward function:
function event = eventForward(place, index, delay)
% Define an event to forward an entity to a storage or output
event = matlab.DiscreteEventSystem.newEvent();
locType = repmat(char(0),64);
locType = place;
event.type = 'forward';
event.delay = delay;
event.location = struct('type',locType,'index',index); % <--- this is the line referred to in the error
end
I've stripped the block of basically everything else, and have only the following function for when an entity enters input or storage:
function [entity,events] = KnitChangeEntry(obj,storage,entity,~)
if storage == 1
dest = 1 + entity.data.mchnIDX;
events = obj.eventForward('storage',dest,0);
else
events = obj.eventDestroy;
end
end
Have I misunderstood how to forward entries between storage elements? I'm somewhat new to matlab, and I can't really figure out why I'm getting an error here, and not while trying to compile my many other custom blocks that also use eventForward.

Antworten (1)

Walter Roberson
Walter Roberson am 11 Jun. 2024
Verschoben: Walter Roberson am 11 Jun. 2024
newEvent is marked as
methods (Static, Access = private)
so you should not be invoking it yourself.

Kategorien

Mehr zu Discrete-Event Simulation finden Sie in Help Center und File Exchange

Produkte


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by