Why do I receive an error when using eventForward?
13 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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.
1 Commento
Walter Roberson
il 11 Giu 2024
Experiment with
event.location = struct('type', {locType}, 'index', {index});
Risposte (1)
Walter Roberson
il 11 Giu 2024
Spostato: Walter Roberson
il 11 Giu 2024
newEvent is marked as
methods (Static, Access = private)
so you should not be invoking it yourself.
0 Commenti
Vedere anche
Categorie
Scopri di più su Discrete-Event Simulation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!