how can i stop this while loop? it doesn;t finish
이전 댓글 표시
while 1
sim(mdl);
if out.soc_fin(end)-soc_target <= 1.5
break
end
on_line = on_line + 1000;
end
the mdl is simulink that calculate soc,
although the SOC reach the if target, it doesn't finish and SOC is going down,
please help me
답변 (2개)
Catalytic
2024년 4월 19일
if abs( out.soc_fin(end)-soc_target ) <= 1.5
Another way is to use isequal function
if isequal((out.soc_fin(end)-soc_target),1.5)
break
end
댓글 수: 1
DGM
2024년 4월 19일
That's only going to work if the error is exactly 1.5. If it undershoots the maximum allowable error, it'll just keep going.
카테고리
도움말 센터 및 File Exchange에서 Signal Attributes and Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!