I could finally figure it out. You can save the data in the handles of the given GUI. So for example if your GUI is named "MyGUI" and you want to save the matrix M, then you can save data within a fuction as the following:
handles.MyMatrix = M; guidata(MyGUI,handles);
This will allow you to reach the values stored in M from any function, and then you can plot it, save it.