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

1 回表示 (過去 30 日間)
Soumyadeep
Soumyadeep 2014 年 1 月 11 日
コメント済み: Soumyadeep 2014 年 1 月 12 日
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.

採用された回答

Amit
Amit 2014 年 1 月 11 日
that's because tableData is undefined in pushbutton2_callback.
add global tableData; before a = str2num(tableData). this will make tableData accessible in that function.

その他の回答 (2 件)

Image Analyst
Image Analyst 2014 年 1 月 11 日
You need to get tableData again in that other callback:
tableData = get(handles.vi, 'Data');
This is safest because if you just make it global, you don't know if those functions, for example update_Callback() has been called yet. Plus, your user might interactively change the table data and that won't be reflected in the tableData global variable unless you've called get() after that and it was declared global in the function where you called the get().

Soumyadeep
Soumyadeep 2014 年 1 月 12 日
so now is tableData a matrix?

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by