Matlab function can't reach 2nd element of the input.

조회 수: 1 (최근 30일)
Ahmet Erikan
Ahmet Erikan 2021년 7월 24일
댓글: Ahmet Erikan 2021년 7월 24일
When I try to run the simulink file shown below, I get the following error.
"Index expression out of bounds. Attempted to access element 2. The valid range is 1-1. More informationFunction '6DOF_Body/wb2Euler' (#29.69.70), line 5, column 13: "2" Launch diagnostic report."
However, the input signal is a 3 element vector. It's the output of 3 integrators joined with a mux. All the dimensions on the simulink file seems alright to me but I keep getting the same error. Why do you think that happens? Thank you for your answers. Here's the code and the simulink file:
function Euler_dot = wb2Euler(wb, Euler)
phi=Euler(1);
theta=Euler(2);
if (theta==pi/2)
theta=(pi/2)+0.001;
end
Rinv=[1 sin(phi)*tan(theta) cos(phi)*tan(theta);0 cos(phi) -sin(theta);0 -sin(phi)*sec(theta) cos(phi)*sec(theta)];
Euler_dot=Rinv*wb;
  댓글 수: 1
Ahmet Erikan
Ahmet Erikan 2021년 7월 24일
Update: The problem seems to be with the Matlab Fcn or my code. I used a subsystem of simulink blocks to replace my Matlab Fcn block and it works just fine now. I'm still curious about what I did wrong with that part so any comment is appreciated. Thanks.

댓글을 달려면 로그인하십시오.

답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 7월 24일
In your simulink model, a mutiplication block (?) has to have matrix multiplication operation. The elementwise multiplication is by default that has to be changed to a matrix multiplication operation.
  댓글 수: 1
Ahmet Erikan
Ahmet Erikan 2021년 7월 24일
Thank you. I believe you're referring to the multiplication with Lbe and yes, I have indeed missed that part. However, that wasn't the problem. I fixed it and I still get the same error. The "Euler" input of the Matlab Fcn "wb2Euler" has 3 element input but when I try to reach the 2nd element, it tells me that the index is out of bounds.
Thanks again for noticing another mistake that would create a problem in the future though. Here's the full picture of the simulink file:

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Sources에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by