[Scilab-users] for-loop error
anna28
parravicini.anna at gmail.com
Thu Oct 29 11:55:04 CET 2020
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
--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
More information about the users
mailing list