Setting Look Up Table parameter 'Table' from GUI using set_param

4 ビュー (過去 30 日間)
Shyam
Shyam 2013 年 4 月 14 日
コメント済み: jason miller 2021 年 2 月 23 日
I want to set the LUT parameter 'Table' frm a GUI:
Lookup Table (n-D): ..... simulink library block
Table data: wArray
Breakpoints 1: ........
I am writing the following code in edit callback in GUI:
wNewVal = str2double(get(hObject,'String'));
w=wNewVal;
wArray=[w w 0 0 -1*w -1*w 0 0]
set_param('SDH/Tp/w','Table','wArray')
i can run the code without any errors but if i run my simulation..i get the following error:
Error evaluating parameter 'Table' in 'SDH/Tp/w'
Caused by:
Undefined function or variable 'wArray'.
See this also:
get_param('SDH/Tp/w','Table')
ans =
wArray

採用された回答

Kaustubha Govind
Kaustubha Govind 2013 年 4 月 16 日
The code in the GUI Callback creates variables in the callback function workspace. Do you run the simulation from the function or independently? If you run it using the SIM command from the function, use this syntax:
options = simset('SrcWorkspace','current','DstWorkspace','current');
sim('mymdl', [0 duration], options)
Otherwise, make sure that the variable 'wArray' is created in the base workspace, because that's where the model looks for it:
wNewVal = str2double(get(hObject,'String'));
w=wNewVal;
wArray=[w w 0 0 -1*w -1*w 0 0];
assignin('base', 'wArray', wArray);
set_param('SDH/Tp/w','Table','wArray')
  2 件のコメント
Shyam
Shyam 2013 年 4 月 16 日
i had done the second option and its working fine...thanks
jason miller
jason miller 2021 年 2 月 23 日
I have a simiar issue... How do you create a variable in the base workspace within the app?

サインインしてコメントする。

その他の回答 (1 件)

SENTHILKUMAR
SENTHILKUMAR 2015 年 10 月 27 日
For the above question, How will you set the values for Breakpoints. When I try to do that in a same way which was mentioned. I am getting the following error
Lookup_n-D block does not have a parameter named 'Breakpoints'.
It recognizes tabledata parameter but not breakpoints parameter. How to overcome that?
  3 件のコメント
Kurt Stewart
Kurt Stewart 2019 年 1 月 14 日
Thanks that works perfect
Kurt Stewart
Kurt Stewart 2019 年 1 月 14 日
'TableData' is the name for the table data if people are wondering

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeModel, Block, and Port Callbacks についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by