|Original Message (ID '32071') By Bill Simpson:|
|I inserted some Print; to see what was going on.
For[i=1, i≤numofseg, i++
but numofseg==1 so your For will only execute one time. If you put Print["i is ", i]; just inside your For you can verify this
Inside your For you have
if[Mod[i, 2] == 0,thenpart,elsepart]
so with i==1 it seems like only the else part will execute. But when I put a Print inside the thenpart and elsepart I see both Print!
AHA! Look carefully at "if[Mod[i, 2] == 0," Notice that is not "If[Mod[i, 2] == 0,", see that lack of capitalized I in If!
I do see one error message about 1/0 and two error messages about part 2 and 3 of t does not exist. Those really should be tracked down.
Now why?!?! is the thenpart and elsepart both executing... AHA! Look carefully at "if[Mod[i, 2] == 0," Notice that is not "If[Mod[i, 2] == 0,", see that lack of capitalized I in If! When I correctly capitalize that If I see that only the elsepart now executes.
Perhaps someday Mathematica will include a "novice mode" that will point out incorrectly capitalized reserved words and other things that repeatedly bite new users and even some experienced people. It took me repeated tries before I noticed what the error was.
So fix that error and see if you still have problems.|