Please refer to simulink example on grid connected PV system. It is already provided in MATLAB 2014.
If you are using an older version of matlab, you can download the file from the link below:
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!