Borrar filtros
Borrar filtros

embedded matlab function error

1 visualización (últimos 30 días)
muhammad saad  malik
muhammad saad malik el 13 de Mayo de 2015
Comentada: muhammad saad malik el 14 de Mayo de 2015
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

Respuesta aceptada

Walter Roberson
Walter Roberson el 13 de Mayo de 2015
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 comentario
muhammad saad  malik
muhammad saad malik el 14 de Mayo de 2015
good answer, thanks, it really solved my problem

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by