Problem with the use of “eig” in a Simulink Matlab function

조회 수: 7 (최근 30일)
Alessandro Mignocchi
Alessandro Mignocchi 2021년 12월 28일
편집: Christine Tobler 2022년 1월 3일
Hi,
we are implementing a Simulink model to retrieve the components of Quaternions from attitude determination block. While using the command "eig" in a matlab function, in order to retrieve the eigenvector corresponding to the maximum eigenvalue, with this procedure:
function q_eigen = fcn(K)
[q_e,lambda] = eig(K);
[lambda_max, col] = max(max(lambda));
q_eigen = q_e(:,col);
end
Simulink dispalys the error "Inferred complexity ("on") for data "q_eigen" does not match back propagated complexity ("off") from Simulink."
We have tried to put "real" command before q_e, but we obtain the same result.
  댓글 수: 2
Walter Roberson
Walter Roberson 2021년 12월 28일
Is it possible that any eigenvalue could be complex?
Christine Tobler
Christine Tobler 2022년 1월 3일
편집: Christine Tobler 2022년 1월 3일
I don't know much about this, but the following older question seems related
and has some answers that to me seem promising to try out.
Using
q_eigen = real(q_eigen);
at the end of the function might remove this error, but unless you are very certain these eigenvectors are actually guaranteed to be real, it will mean returning a wrong result, since the imaginary component shouldn't just be discarded if it exists.

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

답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 12월 28일
편집: Sulaymon Eshkabilov 2021년 12월 28일
Maybe you can try max(max(real(lambda))) instead of real(q_e) to see your Simulink model simulation even though your eigenvalues are complex-valued.

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by