I have a code but its a very crude method in which we first perform RGB-> HSI csc and then since the code used for us was for the cricket matched hence the green field is segmented .....if u need then i will post the code
Image segmentation is a very broad subject. Matlab has so many different methods and examples. It all depends on your end goal and the subject that you are segmenting. You could use threshold, edge detection, seeding, etc.
Yeah, Segmentation also depends on image sematics so the type of image and what you are looking for matters. It is an experimental process so you can try as mentioned above. Good luck:)
as the other answers already imply image segmentation is a very broad subject and there is no general method available in matlab. Anyway, a good start is the K-Means approach that is available in the Image Processing Toolbox. Another good starting point is Matlab Central where you may find a bunch of methods that might fit to your question:
If you are interested in brain image segmentation I can also recommend the code from José Vicente Manjón (suggested above by Montserrat) or from Jussi Tohka: