필터 지우기
필터 지우기

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????????

조회 수: 1 (최근 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
Mohammad Abu Bakar Siddique 2015년 7월 23일
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
Mohammad Abu Bakar Siddique 2015년 7월 13일
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
Mohammad Abu Bakar Siddique 2015년 7월 13일
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에서 Simulink Coder에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by