I haven’t run your code, but I would suggest updating your post to reflect how you’ve changed the code. The error looks suspicious in that the sn_complete
line doesn’t seem to have boolean operations, whereas the error says “non-boolean (Missing) used in boolean context”. It could be the real error lies somewhere else, or that with your updates something else is different/incorrect. For example, maybe you didn’t manage to wrap !ismissing
in all the right places, or there’s a mis-placed closing parenthesis.
Also as an unrelated notes, I notice some code that is not idiomatic Julia. For example, you may be unnecessarily copying the data with stuff like df[:, "LV_acc_mps2"]
. Perhaps you can directly access with df."LV_acc_mps2"
or df[!, "LV_acc_mps2"]
? Also, this seems to copy a column: last(df[:,"time_complete"])
and might be replaced with df[end, "time_complete"]
? This is a trivial thing, but to me it’s nicer to use size(Time, 1)
instead of size(Time)[1]
.
Similarly, collect
allocates memory, often unnecessarily, so maybe you can just use Time = 0:delta_T:last_time
and for t in 1:ts-1
? Another suggestion: Instead of your rectifying ifelse
s, maybe combine each with the preceding line, e.g. vn_complete[t+1] = max(0, vn_complete[t] + (bn...
? Reads a bit clearer to me, although your mileage may vary.
Of course, better to find the bug first, and worry about silly optimizations later.