Im really stuck and really need help. So any suggestions would be really appreciated!
Im running a real-time simulation in Simulink with a 6 DoF vehicle model (with inputs from a joystick). One of the inputs to the model is a row vector which needs to be updated depending on the vehicle position. I have made a matrix, of which the rows correspond to the different row vectors that are needed, depending on the position of the vehicle.
How can I switch between the rows of the matrix during a simulation, based on the current position of the vehicle (position is one of the output states of the model)?
I have made it possible for me to know with a an index variable, 'i', when I have to switch to the next row in the matrix. I did this with a 'Matlab Function' block that uses a series of nested 'if else' statements to return a value for i, which corresponds to the row that I need from the Matrix. I tried sending this variable to the work-space and then modify the row I need from the matrix, which is put in a 'constant' block with argument:
But unfortunately, I think Simulink initializes constants during the start of the simulation, and I don't think the values can then be updated later: It never switches from the first row to subsequent rows of the matrix, even though the value of 'i' is changing at the right times, and is being called from the work-space using the 'from work-space' block. Also for some reason, I couldn't do this so easily with a 'Matlab function' block as it claims the ':' is "unable to parse".
0 · ·