MATLAB: How do i obtain a matrix from a gui table to multiply it to another matrix

guideMATLABmatlab gui

I want to enter a matrix through a table and multiply it with another matrix.I am using GUIDE.
now update is a pushbutton
function update_Callback(hObject, eventdata, handles)
global tableData;
tableData = get(handles.vi, 'Data');
*
now vi is the tag of the table*
function pushbutton2_Callback(hObject, eventdata, handles)
a = str2num(tableData);
a = a*r;
set(handles.test,'String',a);
guidata(hObject, handles);
* **now test is a static text.
Here the problem is that MATLAB says tableData is undefined.** *
Please some one help me out with this.

Best Answer

that's because tableData is undefined in pushbutton2_callback.
add global tableData; before a = str2num(tableData). this will make tableData accessible in that function.