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

조회 수: 2 (최근 30일)
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];

채택된 답변

kintali narendra
kintali narendra 2016년 6월 8일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Naming Conventions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by