필터 지우기
필터 지우기

Getting error "Output argument 'y' is not assigned on some execution paths" Trying tp generate pwm for duty cyle value coming from a PI controller for converter control

조회 수: 2 (최근 30일)
So guys im trying to generate PWM by using while loop. The reason im doing so is that the other blocks in matlab are not functioning as I want. Im attaching my code below, for which im getting simulation errors, one of which is mentioned in the title.
error: Output argument 'y' is not assigned on some execution paths

답변 (1개)

Sabin
Sabin 2023년 1월 30일
As there is a possibility to not enter the while statement, the solver will think that ‘y’ might not be assigned any value in the first branch. The code can be rewritten in a slightly different way as below. This code will run but can be further optimezed probably depending on the requirements.
function y = fcn(u)
a = 50000;
r = u*a;
count = 0;
if r < a
y = 0;
while count < a
if count <= r
y = 10;
end
count = count + 1;
end
else
y = 0;
end

카테고리

Help CenterFile Exchange에서 Clocks and Timers에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by