MATLAB: How to change the Input data of the Constant Block When the sampling time comes

control systemdigital signal processingMATLABsimulationsimulink

I want to change A and B values when the sampling time comes and do subtraction operation on Simulink.
The vectors A and B, as well as the sampling time, are created in the workspace. I add them to Simulink with Constant Blocks.
A = [ 3 5 7 9 ] , B = [1 2 3 4 ] , Ts= 0.1
On the right side of the figure, it can be seen that the Output is 4 parallel data (Data1 , Data2 , Data3 , Data4) when the sampling time comes. But I just want to give all datas of A and B with serial respect to sampling rate and just observe OUTPUT = Data1 on the table. Please Help me.
In Example: A = A[1] = 3 , B = B[1] = 1 at Time = 0
A = A[2] = 5 , B = B[2] = 2 at Time = 0.1 = 1*Ts
A = A[3] = 7 , B = B[3] = 3 at Time = 0.2 = 2*Ts
A = A[4] = 9 , B = B[4] = 4 at Time = 0.3 = 3*Ts

Best Answer

You would have to use sim() after having set a termination time on the model. Then you would set_param() to set the conditions of the block, and then you would set new boundary conditions and new termination time and sim() again.
I do not understand what you are trying to accomplish, but I am certain that changing the parameters of Constant blocks during running is not a good solution. What you are looking for looks to me to be closer to a From Workspace block that has been set not to interpolate.