0
votes

This is a fairly simple thing I think, but I cannot seem to get the right output that Im looking for. I am using matrices to represent state space models in simulink, and I am trying to get my states output to the workspace,

it is a simple 4x1 vector, and I tried just using the regular "to workspace" block, but it seems it concats to either a 2d or 3d vector..

I want to have a tx4 matrix output that I can reference the first state and plot for all simulation time(t) like x(:,1), the second state x(:,2) etc...

1

1 Answers

1
votes

You can set a save format in a To Workspace block. Default this is set to timeseries, but you can set it to Array.

Looking at the doc for the Array setting:

If the input signal is a scalar or a vector, each input sample is output as a row of the array. Suppose that the name of the output array is simout. Then, simout(1,:) corresponds to the first sample, simout(2,:) corresponds to the second sample, and so on.

You want the first dimension not to be time, but your state vector, so transposing simout should do the trick.

simout = simout.';    % or tranpose(simout);