1 / 19

Simulink and mfile

Simulink and mfile. In this section, we will look at GUIs with Simulink Programming GUIs using mfiles. GUI with Simulink. GUIs can be used with Simulink to Open a Simulink file Send parameters to a Simulink file Simulate a Simulink file Extract data from a Simulink file.

conor
Download Presentation

Simulink and mfile

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Simulink and mfile In this section, we will look at GUIs with Simulink Programming GUIs using mfiles

  2. GUI with Simulink GUIs can be used with Simulink to Open a Simulink file Send parameters to a Simulink file Simulate a Simulink file Extract data from a Simulink file

  3. GUI with Simulink To open a Simulink file, type >>open_system(‘Filename’)

  4. Example Create a Simulink file that outputs a sinewave Create a GUI to set the amplitude, frequency and phase shift of the sinewave. Then plot the results.

  5. Example Make sure that your output is an Outport Note the name given to the block (you can change if you want)

  6. Example Note these field names If you open the Sine Wave block, you get

  7. Example Now create the GUI

  8. Example Now program the Pushbutton Callback Open the Simulink file >>open_system(‘SimulinkExample’); The name of your Simulink file

  9. Example Get the user entered values and set them into the Simulink file >>amp=get(handles.edit1,‘string’); >>set_param(‘SimulinkExample/Sine Wave’,‘Amplitude’,amp); ‘Filename/Blockname’ Field name (take only 1st word)

  10. Example Get the user entered values and set them into the Simulink file >>freq=get(handles.edit2,‘string’); >>set_param(‘SimulinkExample/Sine Wave’,‘Frequency’,freq); ‘Filename/Blockname’ Field name (take only 1st word)

  11. Example Get the user entered values and set them into the Simulink file >>phase=get(handles.edit3,‘string’); >>set_param(‘SimulinkExample/Sine Wave’,‘Phase’,phase); ‘Filename/Blockname’ Field name (take only 1st word)

  12. Example Simulate the Simulink file >>[timeVector,stateVector,outputVector]=sim('SimulinkExample'); The 3rd output argument will give you the data of the ‘Outport’ Names you can assign

  13. Example Plot the results >>plot(timeVector, outputVector)

  14. GUI by programming It is also possible to create a GUI by command line programming without using GUIDE Use the command ‘uicontrol’

  15. GUI by programming The format of programming a uicontrol is as follows >>h=uicontrol(‘Property1’,value, ‘Property2’, value,…)

  16. GUI by programming Property Property For example, to create a Pushbutton >>h=uicontrol(‘style’,‘pushbutton’,‘units’,‘normalized’, ‘position’, [0.1 0.2 0.3 1.1]) value value value Property

  17. GUI by programming What are the possible fields for Property? units, style, position, callback, string, fontsize, visible, enable Basically, whatever you can find when you double-click a component in GUI

  18. GUI by programming All possible property fields Value fields

  19. Conclusion: this course The principles of GUI in Matlab How to create a GUI using GUIDE How to output messages/dialogs How to create menus GUI with Simulink and programming Use ‘help’ commands in Matlab to know more

More Related