MATLAB: Vector input for MATLAB function block

matlab function blockmultiple inputssimulink

Hello everyone,
I've been struggling with this problem for a while now and it's beginning to drive me mad:
I have a Simulink MATLAB function block that is supposed to perform some calculations with the last 100 values of a signal. Is there a way to dynamically store the last 100 values of said signal and feed it as an input into the MATLAB function block without using 100 inputs and thousands of memory blocks?
Best regards,
Daniel

Best Answer

Well, although your problem is ok, usage of Memory block always increases the chance for system to fail if the complexity of your system increases. The best way to hold the value of a signal is to use Enabled Subsystem and that is what I did. I also kept your way and made a comparison. My way also works, see if that helps to you. Notice how I used the Pulse Generator. I also changed the solver type to variable-step since I wanted both your way and my way to take the same step size while solving.