I want to use a persistent variable inside a matlab function block but I can't initialize it. I want to either initialize it from an m.file or do it inside the function.
If I use isempty then the variable is given a size of 1x1 and I don't want that. Basically I don't know how to handle the persistent value as it is taken as 1x1 or as not defined. How can I use isempty but do not give it a 1x1 size? Or how can I initialize it from an m.file?
function y1 = fcn(u)
persistent y;
if isempty(y)
y=0;
end
for i=1:1:length(u)
if u(1,i) >=10
y(1,i) = 1;
elseif u(1,i) <= 5
y(1,i) = 0;
else
;
end
end
y1=y;
end