simplesimon

24 Reputation

2 Badges

16 years, 289 days

MaplePrimes Activity


These are answers submitted by simplesimon

Yes, k should be n...
I see what you're saying. It's a copy paste error as you presumed. Below is the procedure treach as it should've been: treach:= proc(pl,sl,trchmax,trchstart,trchend) > local speed; > if pos[n]>=trchstart and pos[n]<=trchend then speed[n]:= min(speed[n],trchmax) > else if pos[n] end if; end if; > end proc: This procedure is meant to simulate a treacherous strech of track on a cycling track. So a cyclist on this strech is forced to slow to a max speed trchmax from the start of this part of this part of the track trchstart until the end, trchend. I also forgot to define the max speed of the cyclists in the initial conditions so vmax:=5 After making the corrections the procedure runs without error but doesn't do what it's meant to. i.e slow the cyclists to 2 between position 17 and 25 on the track! I've been staring at it for hours and can't see where i've gone wrong.
Thanks Acer, I removed pos as a local variable but now the resulting error is: Error, (in treach) cannot determine if this expression is true or false: 17 <= [4, 10, 16, 22, 28, 34, 40, 46, 52, 58][n] and [4, 10, 16, 22, 28, 34, 40, 46, 52, 58][n] <= 25 Surely it should compare 17 to the nth item in the list?
I've updated the last bit which seems to give me what i'm looking for but it doesn't display the correct speeds and it seems my code is very inefficient: for k to N do > pos:= bicycle(pos,speed,L); > speed:= vel(pos,L,8); > for n to N do > if pos[n]>=17 and pos[n]<25 then speed[n]:=min(speed[n],trechmax) > else if pos[n]<=17 and (17-pos[n])<8 then speed[n]:=max(17-pos[n],3) end if; > end if; > end do; > end do;
Page 1 of 1