It would be really helpful to get any information about what you have tried and why it is not working (wrong result, error messages?). Are you using guide, appdesigner or do you create your gui programmatically?
There are several ways to pass data between functions in Matlab, detailed information about this topic can be found here.
A MWE featuring guidata:
pb(i)= uicontrol('style','pushbutton','string',sprintf('Button%d',i),'position',[20+80*i 50 80 40]);