index must be a positive integer or logical error
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
David
le 22 Oct 2013
Réponse apportée : Walter Roberson
le 22 Oct 2013
I have defined a 3x443 matrix q in a quasi-1D CFD solver written as a Level II MATLAB S-Function. At iteration 53726 the Simulink simulation stops and I get the following error message:
Error evaluating registered method 'Outputs' of MATLAB S-Function 'File_S2' in 'File_SM_V1/Nozzle/Level-2 MATLAB S-Function'. The following is the MATLAB call stack (file names and line numbers) that produced this error: ['/home/APSE/Simulink/File_S2.m'] [245]
Caused by: Attempted to access q(2,1); index must be a positive integer or logical.
I don't understand the error since '2' and '1' are both positive integers and q(2,1) exists. Any advice on what could be causing the error would be appreciated.
0 commentaires
Réponse acceptée
Walter Roberson
le 22 Oct 2013
It could be that the 2 or 1 are the printable representations of numbers very close to 2 or 1.
Put a breakpoint in at that line, and check the indices, subtracting the value that it appears to be from the actual variable holding the index. Make sure you are using
format long g
to get the proper printout.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!