Index exceeds the number of array elements
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Steven Lord
am 18 Aug. 2022
Without seeing your Simulink model it's going to difficult if not impossible to offer any concrete suggestions for how to avoid this error.
Antworten (1)
Shivani Dixit
am 26 Aug. 2022
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:
- 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 Kommentare
Shivani Dixit
am 1 Sep. 2022
Hello,
The answer above mentions a possible situation that your model must have encountered.
I suggest you the following workarounds:
- 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.
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!