Create a MaxRunningResettable

Hello. I need to program a userdefined function. The function should be named “MaxRunningResettable.” It should output the maximum of all previously entered values. Additionally, it should be reset by another input signal (PULSE_SC).
This is my code:
function y = MaxRunningResettable(input, hold)
persistent maxVal;

if isempty(maxVal)
    maxVal = input;
end

maxVal = max(maxVal, input);

if hold ~=0
    maxVal = 0;
end

y = maxVal;

endfunction
now i use the scifunc_block_m with this settings:
image

but if I try out the block with a sine wave at the first input port an erro occurs. I cant identify the problem. I hope someone can help me.
thanks.

image

I found my mistake:
there is no variable type: persistant. instead use global. And the inportsize has to be [1,1;1,1].