Index exceeds the number of array elements

조회 수: 18 (최근 30일)
SALAH alatai
SALAH alatai 2022년 8월 14일
댓글: Shivani Dixit 2022년 9월 1일
I am doing normal simulink for a cricuit includes normal elements like mosfet,capacitor, inductor and transformer whaen I run the circuit i received this ereor:-
Warning: Matrix is singular to working precision.
Index exceeds the number of array elements. Index must not exceed 0.
Component:Simulink | Category:Model error
can anyone help pls.
thanks
  댓글 수: 5
SALAH alatai
SALAH alatai 2022년 8월 18일
up
Steven Lord
Steven Lord 2022년 8월 18일
Without seeing your Simulink model it's going to difficult if not impossible to offer any concrete suggestions for how to avoid this error.

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

답변 (1개)

Shivani Dixit
Shivani Dixit 2022년 8월 26일
Hello,
I understand that you get the error “Matrix is singular to working precision“ while executing your Simulink model.
The following could be the cause of the issue:
  1. A major possibility is that you have encountered a roundoff error that demonstrates a fundamental problem with the way computers deal with numbers of vast differences in magnitude.
Since the machine uses a finite number of bits to represent any number (in MATLAB's case, 64 bits are used), matrices that are poorly scaled are difficult to work with. One way to visualize the problem is using a 2-dimensional system. As an example, consider “A” as a simple non-singular matrix:
>> A = [1 0 ; 0 1];
The two column vectors in this matrix are as linearly independent as possible. However, if we stretch one vector and shrink the other, the matrix becomes closer to [k 0; 0 0], which is singular.For the smaller number, some precision is lost because the computer has difficulty representing both numbers with the same amount of accuracy.
>> format long
>> A=[2^50 0;0 2^(-50)]
A =
1.0e+015 *
1.12589990684262 0
0 0.00000000000000
Note that, although the machine could represent 2^(-50) by itself, it has lost the number's true value here, because it needs to deal with larger numbers at the same time.
So, even if this matrix is still non-singular in the true world of mathematics, it is singular to working precision on the computer, and singular matrices can cause the same kinds of problems that division by zero causes.
  댓글 수: 2
SALAH alatai
SALAH alatai 2022년 8월 28일
@Shivani Dixit Thanks for your response, but I do not understand how to solve the problem.
Shivani Dixit
Shivani Dixit 2022년 9월 1일
Hello,­­­
The answer above mentions a possible situation that your model must have encountered.
I suggest you the following workarounds:
  1. You must check for the inputs (matrices, vectors if any), output or any data being fed to your model that may cause this issue in your model as mentioned above. If such a data exists, please try the following workaround:
As mentioned above, for smaller numbers, some precision may be lost because the computer has difficulty representing both numbers with the same amount of accuracy, example:
>> format long
>> A = [2^50 0;0 2^(-50)]
If you find data similar to this, try using the symbolic toolbox:
>> format long
>> A=[sym(2^50) 0 ; 0 sym((2^(-50)))]
This would help you resolve this issue. There are several other tools that you can take help of when dealing with large numbers, for more information you can refer to the following answer:
If the above workaround does not work, please check whether you get same warning message in other standard models. If not, please share a dummy model which is similar to your current model so that I can reproduce the issue on my end and help you better.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by