You will not encounter this issue if use MATLAB R2020b or later. As a workaround, this can be resolved by specifying the LD_LIBRARY_PATH before creating the node:
setenv LD_LIBRARY_PATH <matlabroot>/extern/bin/glnxa64:<matlabroot>/sys/os/glnxa64
It should work fine after doing the above step and should be able to create publisher and subscriber. If you still see the same error, try doing this worksround:
Create a publisher on a default topic :
pub = ros2publisher(node,"/paramete_events")
Then create your publisher:
pub = ros2publisher(node,"/example_topic")
This should work, Hope this helps!