how can i sync simulink model with gui? i tried several functions but it nothing heppend still there is problem. i tried SET_PARAM but no result. could any one tell me the proper solution how can i update this problem????????

3 次查看(过去 30 天)
Simulink with gui sync

采纳的回答

Ilham Hardy
Ilham Hardy 2015-7-9
what do you actually mean with synchronization with GUI?
Do you want to update GUI values/graphs based on Simulink model when the model is running? Then you may want to check this demo ( Event Llstener )
Do you want to update/set Simulink model parameter using the GUI? then the set_param/get_param is the correct way to proceed.
  9 个评论
Mohammad Abu Bakar Siddique
Thanks Ilham
thats a new problem i have. i couldn't find realtime workshop in model configuration parameter in (matlab2013b). i tried but i couldn't. what should i do right now could you please tell me
Regards Abu Bakar
Ilham Hardy
Ilham Hardy 2015-7-30
Hi Abu,
Depending on your Matlab version, the Real-time Workshop (RTW) might have been updated to Simulink Coder .
This is a separate toolbox, not included in default Matlab software package. Which also means you have to buy for it separately.
To interface microcontroller with Matlab/Simulink, Embedded Target can be used. However, as far as I know, to use the Embedded Target you need to have Simulink Coder toolbox.

请先登录,再进行评论。

更多回答(2 个)

Mohammad Abu Bakar Siddique
Dear Ilham Hardy
Yes I want to update simulink model parameters values with the help of GUI. I used set_param but it is not working if you give me some examples that will really much more kind of you.
Md Abu Bakar Siddique

Mohammad Abu Bakar Siddique
here is the code for updatine the sinewave value in gui
function edit_mag_Callback(hObject, eventdata, handles) % hObject handle to edit_mag (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit_mag as text % str2double(get(hObject,'String')) returns contents of edit_mag as a double handles=guidata(hObject); val=get(hObject,'string'); set(handles.slider_mag,'value',str2double(val)); set(handles.Matlab_simulink/SineWave/Amplitude,'Amplitude',num2str(val));
set_param(Matlab_simulink/SineWave/Amplitude,'Amplitude',val); %set_param(Matlab_simulink/SineWave/Amplitude,'SineWave',val); %set_param(Matlab_simulink,'Matlab_simulink/SineWave/Amplitude','Amplitude','value'); guidata(hObject,handles);
% --- Executes during object creation, after setting all properties. function edit_mag_CreateFcn(hObject, eventdata, handles) % hObject handle to edit_mag (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
% --- Executes on slider movement. function slider_mag_Callback(hObject, eventdata, handles) % hObject handle to slider_mag (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'Value') returns position of slider % get(hObject,'Min') and get(hObject,'Max') to determine range of slider val=get(hObject,'value'); %put the value to text
set(handles.edit_mag,'string',val); %Update SIM model %set_param(Matlab_simulink/SineWave/Amplitude,'Amplitude',val); set_param(Matlab_simulink/SineWave/Amplitude,'SineWave',val); guidata(hObject,handles);
  • here is the error message *
Undefined function or variable 'SineWave'.
Error in Simulink_Gui1>slider_mag_Callback (line 186) set_param(Matlab_simulink/SineWave/Amplitude,'SineWave',val);
Error in gui_mainfcn (line 96) feval(varargin{:});
Error in Simulink_Gui1 (line 42) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)Simulink_Gui1('slider_mag_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback

类别

Help CenterFile Exchange 中查找有关 Naming Conventions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by