Hello,
This is a very popular subject and there are different resources we have available. First I would suggest just running a simple search of the forum for the questions other users have asked. Using their examples it should be possible to get a good understanding of how it works.
You can also check out our video section and tutorials for help on the subject:
Matlab Binary Switch
If you are still having trouble feel free to post your OptiSystem project file and Matlab file to this topic and I can help you troubleshoot it and get it working!
Regards
+4