|
Hi there,
What I have is a simple Simulink model consisting of a scope, embedded MATLAB function block and an IC block. The signal route, if assumed to start from the output of the function block goes to the input of the IC block. The output of the IC block goes to the input of the function block to form a loop. The scope shows the output from the function block. The initial condition of the input block is set to 1 and the embedded MATLAB function is y = u + 1. The sampling time has been set to 1 sec and the simulation runs for 10 secs. The expected output in the scope would be an initial value of 1 and then an increment of 1 every second, however this is not the case. This signal ramps unexpectedly and the output for the first few seconds is shown below (found using the Simulink debugger U1 = input and Y1 = output of matlab function):
%----------------------------------------------------------------%
[TM = 0 ] untitled.Simulate
probe: Data of 0:0 SubSystem block 'untitled/Embedded MATLAB Function':
U1 = [0]
Y1 = [0]
(sldebug @0):
%----------------------------------------------------------------%
[TM = 0 ] untitled.Outputs.Major
(sldebug @28):
probe: Data of 0:0 SubSystem block 'untitled/Embedded MATLAB Function':
U1 = [1]
Y1 = [0]
(sldebug @28):
%----------------------------------------------------------------%
[TM = 1 ] untitled.Outputs.Major
(sldebug @28):
probe: Data of 0:0 SubSystem block 'untitled/Embedded MATLAB Function':
U1 = [4503599627370497]
Y1 = [4503599627370498]
(sldebug @28):
%----------------------------------------------------------------%
[TM = 2 ] untitled.Outputs.Major
(sldebug @28):
probe: Data of 0:0 SubSystem block 'untitled/Embedded MATLAB Function':
U1 = [9007199254740992]
Y1 = [9007199254740992]
As can be seen, at TM = 1 the signal jumps (and the plus one is still carried out). U1 does not equal Y1 from the previous step. Does anyone know why? And how to fix it? At first i thought it might be from the embedded MATLAB function continuously looping around but i don't think that is it.
Any suggestions would be most appreciated.
Thank you,
James
|