The first thing you will need to do is make sure your protocol is set up to have the hand feedback “Controlled by task program”. That value is set on the “General” tab when you edit your protocol. There are a few options for your simulink code. The easiest option is to use the “KINARM Distance from Target” block in the KINARM General library. This will output an array of distances to each target in your target table. In that sense it can be used much like the KINARM Hand In Target block.
One potential approach is to:
Output a state from your stateflow code indicating if the hand feedback must be on, must be off, or can be on if close enough to the target.
Output the target number to be looking at from stateflow (likely you are already outputting this to the show target block)
Take the outputs above and the output of the Distance from Target block and put them into a MATLAB function. The output of the function is zero if the feedback should be off, 1, 2, or 3 depending on the value you want to pass into the hand feedback block (check out the hand feedback block’s help for what each of those mean).