Hi,
Are you sure that all the strings in matrix have at least 20 characters? PS: Not related to the index issue but probably not a good idea to use a variable with same name as existing function matrix. Regards, Rafael -----Original Message----- From: users <[email protected]> On Behalf Of anna28 Sent: Thursday, October 29, 2020 12:55 PM To: [email protected] Subject: [Scilab-users] for-loop error Hello all, 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: "Nentries=283; Nticks=20; Nstep=15; for j=1:Nticks k=j*Nstep; disp("j="+string(j)+"; Nstep="+string(Nstep)+"; k="+string(k)+" j*Nstep="+string(j*Nstep)); if(k<=Nentries) then str1=strsplit(matrix(k,1),[11,20])(2); str2 = strsubst(str1, "_","="); else str2="="; end tick_array_step_rot(j)="$\text {\rotatebox{90}{"+str2+"}}$" end" 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? many thanks Anna
_______________________________________________ users mailing list [email protected] http://lists.scilab.org/mailman/listinfo/users
