"...to add the count from each truck to the global variable COUNTER."
Ugh, who teaches this material to impressionable students?
"but i know im using function and global incorrectly and im not sure what else to do"
How about following the instructions that you have been given?:
"Create two user-defined MATLAB functions called PBTask4p2a_f.m ... and PBTask4p2b_f.m ..."
You have not created to two functions, which is what the very start of your assignment tells you to do.