필터 지우기
필터 지우기

How do you update row vector elements during a real-time simulation in Simulink?

조회 수: 2 (최근 30일)
Hey Guys
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:
Matrix(i,:)
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".
Please Help!!!
ESunil

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2012년 8월 6일
편집: Azzi Abdelmalek 2012년 8월 6일
i think you can use a "multiport switch" block with n+1 iputs, n inputs for your rows and 1 for the control signal

추가 답변 (1개)

Giorgio Concu
Giorgio Concu 2017년 11월 22일
Hi! I have the same problem, but I have to uptade a 125x1 vector so it is not smart to implement a multiport switch. Do you have any other suggestions? Thank you!

카테고리

Help CenterFile Exchange에서 Scopes and Data Logging에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by