I understand that you are facing an issue with activating the valve in the ROS. The issue might be in the sorted execution order of the subscriber and publisher blocks. But it most likely should not be a MATLAB/ROS clock issue.
You can refer to the following links regarding ROS current time and accessing ROS time functionality:
- https://www.mathworks.com/help/ros/ref/currenttime.html
- https://www.mathworks.com/help/ros/ref/time.html
I hope this helps resolve resolve your issue.