필터 지우기
필터 지우기

embedded matlab function error

조회 수: 1 (최근 30일)
muhammad saad  malik
muhammad saad malik 2015년 5월 13일
댓글: muhammad saad malik 2015년 5월 14일
in embedded matlab function file error is
Undefined function or variable 'y'. The first assignment to a local variable determines its class.
code is here:
function y = fcn(Vreq)
%#eml
Vact=230;
duty=(Vreq/Vact);
Fs=50;
Ts=1/Fs;
i=1;
t=0:Ts:1-Ts
for k=0:Ts:1-Ts
if(k<=duty)
y(i)=1
else
y(i)=0
end
i=i+1;
end
end

채택된 답변

Walter Roberson
Walter Roberson 2015년 5월 13일
Initialize y before the loop.
y = zeros(length(t),1);
Also you can probably change your for loop to
for k = t;
But you can replace your entire for loop with:
y = double(t <= duty);
  댓글 수: 1
muhammad saad  malik
muhammad saad malik 2015년 5월 14일
good answer, thanks, it really solved my problem

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by