Update 21.11.2019:
Please check my submission in the below link:
https://de.mathworks.com/matlabcentral/fileexchange/73613-interface-between-matlab-app-and-simulink
------------------------------------------------------------------------------------------------------------------
In a similar way to GUIDE you can read real-time values from Simulink Model.
app.test.Tag = 'test';
Then work to be done on Simulink Model.
1st Step: Model Properties -> Callbacks ->
% Set up the arguments that will go into the gain block event callback listener
blk = 'modelname/outputportname';
event = 'PostOutputs';
listener = @updateApp; (separate MATLAB function)
% Create the listener
h = add_exec_event_listener(blk, event, listener);
2nd Step: MATLAB Function (updateApp.m)
%create a run time object
rto = get_param('modelname/outputportname','RuntimeObject');
str = num2str(rto.InputPort(1).Data);
% get a handle to the Edit Button in MATLAB App
all_tag_objects = findall(0, '-property', 'tag');
all_tags = get(all_tag_objects, 'tag');
[tf, idx] = ismember('test', all_tags);
if tf
st1 = all_tag_objects(idx);
end
% update the MATLAB App
set(st1,'Value',str2double(str));
0 Comments
Sign in to comment.