SimEvents: Why do I get the error "undefined function or variable 'out1'" in testEntry method?
1 次查看(过去 30 天)
显示 更早的评论
I have modeled a simple server that encounters failure. I want the testEntry method to close the gate of Storage1, when the Failure event is arrived in Storage2. The DES system also outputs some statistics about its status. But it seems that my code has issues with the body of testEntry method, where I want to update signal outputs. Each time I run the model, it throws the following error:
% 'undefined function or variable 'out1'.
% The first assignment to a local variable deterines its class.'.
% The error occurred for MATLAB System block
% 'SimpleServer/MATLAB Discrete-Event System'.
I have written the DES system object file step-by-step and I think the testEntry causes this error, because it was the last method I added. When I remove this method, the model works with no errors. Files are attached.
0 个评论
回答(1 个)
Ashitha Mahendra
2020-2-14
Hi Kar Moh,
If my understanding is not wrong, you are trying to observe the output from the Discrete Event System (DES) block. I also think that testEntry is the function which is causing the error. I see that out1, out2, out3 are not declared as the output.
Usually, any output from the DES block is declared before it is used in any event as shown below:
function [o1,o2,o3] = getOutputNamesImpl(~)
o1 ='out1' ;
o2 ='out2' ;
o3 ='out3' ;
end
You can have look at this link below, where there are two inputs to the DES block similar to your case but with 3 outputs:https://www.mathworks.com/help/simevents/examples/selection-server-select-specific-entities-from-server.html.
You can also try executing the following command alternatively for opening the example in MATLAB:
>>seExampleSelectionServer
This example shows how you can use the MATLAB DES block to write a custom N-Server from which specific entities can be selected using a key lookup. Passengers enter from the IN port of the block and are stored in the block until a message arrives at the KEY port carrying a lookup key (KEY and IN are the inputs which you can have look at and change it accordingly for outputs)
Feel free to look at the link below if you have any questions with syntax of any DES block. The link also has a good number of examples:
https://www.mathworks.com/help/simevents/implement-blocks-with-system-objects.html?s_tid=CRUX_lftnav
Hope this helps to resolve the issue.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Discrete-Event Simulation 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!