Are you sure that all the strings in matrix have at least 20 characters?
Not related to the index issue but probably not a good idea to use a variable with same name as existing function matrix.
From: users <[hidden email]> On Behalf Of anna28
Sent: Thursday, October 29, 2020 12:55 PM
To: [hidden email]
Subject: [Scilab-users] for-loop error
I'm facing a trouble with a (in principle) very basic script... but I really don't understand the reason.
Inside a bigger script, I have the following code:
disp("j="+string(j)+"; Nstep="+string(Nstep)+"; k="+string(k)+"
str2 = strsubst(str1, "_","=");
where "matrix" is a 283x5 string matrix.
It usually works, but it sometimes gives me error of "invalid index" at the line of "str1". That's why I asked to "disp" all the indexes and I find the following output:
j=1; Nstep=18; k=18 j*Nstep=18
j=2; Nstep=18; k=36 j*Nstep=36
j=3; Nstep=18; k=54 j*Nstep=54
j=4; Nstep=18; k=72 j*Nstep=72
j=5; Nstep=18; k=90 j*Nstep=90
j=6; Nstep=18; k=108 j*Nstep=108
j=7; Nstep=18; k=126 j*Nstep=126
j=8; Nstep=18; k=-112 j*Nstep=-112
If I change the matrix and the number of rows, I detect similar problems: at a certain point, the multiplication j*Nstep gets wrong.
Do you have any suggestions?