[Scilab-users] !--error 21

Frieder Nikolaisen Frieder.Nikolaisen at student.hs-rm.de
Thu Oct 6 08:17:31 CEST 2016


Hello everybody,

I do have a code, I cannot find the mistake. I get the error:

"    if A(c-1,3)==0 then
                 !--error 21
ungültiger Index.
at line      11 of exec file called by :
exec('M:\CAD\Abteilungen\Praktikanten\Nikolaisen, 
Frieder\Fahrdaten\Testprogramm\Archive\test2.sce', -1)"

My minimal example Code with random Matrix instead of the real used 
one:

//example code

for c=1:10
A=rand(10:30)
dm=0
vor_starter=0
starter=0

//start of buggy code
if c>=2 then
     if A(c-1,3)==0 then
         if A(c,7)>0 then
             beginnZ=c
             vor_starter=1   /
         end
     end
         //Endzeile festlegen
     if vor_starter==1 then
         if A(c-1,7)>0 then      /
             if A(c,7)<=0 then
                 endZ=c-1
                 starter=1
                 vor_starter=0
             end
         end
     end

     //Berechnung der Zugmasse
     if starter==1 then
         time3=datevec(A(beginnZ,1))
         time4=datevec(A(endZ,1))
         delta_t=etime(time3, time4)
         delta_v=(A(endZ,3)-A(beginnZ,3)*3.6)     // m/s
         length_F=length(beginnZ:endZ)
         mittel_F=sum(A(beginnz:endZ,6)/length_F)
         dm= (delta_t/delta_v) / mittel_F
         starter=0
     end
end

if dm~=0 then
     disp(dm)
end

// end of buggy code

end



The real Matrix Looks like These:
Zeit	Distanz	Geschwindigkeit 1	Drehzahl	Getriebeausgangsleistung 
[Watt]	Zugkraft [N]	Beschleunigung [m/s^2]	Cv-Druck	Richtung		Lokbremse 
anlegen	Lokbremse lösen	Zugbremse anlegen	Zugbremse lösen	Kupplung 
betätigt	Bremsen  aktiv
734962.404654	46476.494	0.00	1150.71	141700	0	0.00	0	0	0	0	1	0	0
734962.404900	46476.494	0.00	1059.06	110500	0	0.00	0	0	1	0	1	0	0
734962.404902	46476.494	0.00	1059.06	110500	0	0.00	0	0	1	1	1	1	0
734962.404971	46476.495	1.70	1059.06	110500	234000	1.04	0	0	1	1	1	1	0
...


Best regards
Frieder



More information about the users mailing list