what is the problem with the second 'IF' loop ? Program terminates after entering into the loop.

1 view (last 30 days)
I am able to enter into the second "IF" but the simulink program terminates after executing the lines in the second "IF" condition. Simulink runs for the required time without the second "IF" condition.
function [Out] = LMAImplementation_Motor(In)
persistent eWithNoChange eWithDeltaL eWithDeltaK
e = In(1);
L = In(2);
K = In(3);
Clock = In(4);
if (0.0000 <= Clock) && (Clock <= 0.9999)
deltaK = 0; deltaL = 0;
eWithNoChange(end+1) = e;
[m,n] = size(eWithNoChange);
end
if n == 30001 %THIS LINE WAS BOLD
eWithNoChange(:,1) = [];
sizeofeWithNoChange = size(eWithNoChange)
end
if (1.0000 <= Clock) && (Clock <= 1.9999)
deltaL = L*0.1; deltaK = 0;
eWithDeltaL(end+1) = e;
end
Out = [deltaL,deltaK,Clock];

Accepted Answer

kintali narendra
kintali narendra on 8 Jun 2016
The issue got solved, As I didn't define the variable "n" the program gets terminated, after defining the variable there is no more issue.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!