Your Xi is StateDim by nCpts and you have StateDim = 8; nCpts = 2*StateDim; so we deduce your Xi is 8 by 16. You pass that into your routine, where it becomes known as Xa .
In your code you create X1, which appears to be 8 x 1 .
You do a matrix multiplication dt * X1 and add that to Xa(:,k) . Since we know that Xa is 8 x 16, we deduce that the result of dt * X1 is required to be 8 x 1.
In order for dt * X1 to yield 8 x 1 when X1 is 8 x 1, dt would need to either be a scalar (in which case the * would silently become equivalent of .*) or else would need to be 8 x 8 . Any other size for dt and you would get the error about inner dimensions needing to agree.
Now what do we the readers know about the actual size of dt? The answer to that is: Nothing. It is a global variable for which you did not show the initialization.
One possibility is that dt is empty inside that routine. That would happen if you never initialized a global dt before you called the routine. Your could would need to have set up with
It is not enough for your code to have initialized with
as that would store only into the local workspace (or perhaps the base workspace) rather than the global workspace.
Best Answer