Тёмный
No video :(

How to simulate a model through App Designer, set parameters and plot outputs in App Designer? 

Programmer World
Подписаться 13 тыс.
Просмотров 43 тыс.
50% 1

This video shows steps to create an App Designer GUI. Further, it shows how we can use the App Designer to set parameters of Simulink model through workspace variable method (using assignin command). It further shows the API to simulate the model for a fixed duration setting the duration using the StopTime argument. And at last it shows the steps to plot the output in the UIAxes using the simout from the sim command.
Complete source code can be found at:
programmerworl...
We will be glad to hear from you regarding any query, suggestions or appreciations at: programmerworld1990@gmail.com

Опубликовано:

 

28 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 95   
@rebaonereba4213
@rebaonereba4213 Год назад
Thank you so much. I’m currently building a learning tool for Power electronics course using Matlab app designer 😅. This was quite helpful.
@chrisdeprosperts1065
@chrisdeprosperts1065 4 года назад
Very useful introduction! Having achieved part of my work based on your sharing. Thank you
@nathanseba270
@nathanseba270 2 года назад
Tank you very much you help me for my internship when I'm blocked since 3 days
@sunilgiri7718
@sunilgiri7718 4 года назад
Thank you for the enlightening video. It is very useful for creating an integrated Simulation environment with App designer.
@wisienkowykompot3649
@wisienkowykompot3649 Год назад
great tutorial thank you very much from the bottom of my heart
@TudorMiron
@TudorMiron Год назад
Thank you for this tutorial. It was helpful.
@smilesmile787
@smilesmile787 3 года назад
This video very good
@heyderlargo9204
@heyderlargo9204 3 года назад
Thank you so much! Very helpful video.
@prasadadavi6618
@prasadadavi6618 2 года назад
Fabulous 👍
@gabrielmq9462
@gabrielmq9462 2 года назад
Me sirvió muchísimo su video, graciasss
@ProgrammerWorld
@ProgrammerWorld 2 года назад
gracias
@mdjamirhossainjamir428
@mdjamirhossainjamir428 Год назад
thank you vary so masuh
@atharvabodhe205
@atharvabodhe205 8 месяцев назад
I am trying to get the output of a frequency v/s time graph from simulink to the app UIAxes. It is giving me error of "Dot indexing is not supported for variables of this type." Sir, can you please explain to me what this error is? This is the code I am using. 'graph' is the name for "to workspace" block simOut = sim('sim_model'); time = simOut.graph.time; frequency = simOut.graph.data; plot(app.UIAxes, time, frequency);
@sriravalikamthamraju6225
@sriravalikamthamraju6225 4 года назад
thank you so much ! this is so helpful !
@raula.6072
@raula.6072 5 лет назад
Nice video! However, I wonder if there's a command that actually lets me see the change in the plot instantly as soon as I change the value in the slide bar, so as to make it more real and interactive. Thanks in advance!
@ProgrammerWorld
@ProgrammerWorld 5 лет назад
It is possible to design the GUI such that the changes are reflected instantly in the plot. For this you simply have to add callback function (value change callback) to the slide bar. And in this call back function rewrite the plot command for the axes. This will refresh the plot immediately for any value change of the slide bar.
@ayushvarun1425
@ayushvarun1425 Год назад
Can you plzz tell me how can we import data from excell to from_workspace block in simulink model....can we do it using assignin function...plzz reply
@tosddk7758
@tosddk7758 3 года назад
Thanks for the video, I would like to know if I would to compile the app to a standalone app for someone else to use, how does the simulation model from Simulink works for them ?
@javierhidalgoescalante3146
@javierhidalgoescalante3146 3 года назад
Hi... I want to set a parameter in a A/C source from an entry of an user in AppDesigner, but wen I do it Matlab says " A/C Source don't exist 'Peak amplitude' parameter'", do you know hoe can I call that parameter? This ir what 'm doing: set_param('SimulinkName/BlockName' , 'Peak amplitude' , app.Vs.Value); (app.Vs.Value is the value from the user un AppDesigner)... This is the matlab error msg: Error using SimulinkName/CacularButtonPushed (line 60) AC Voltage Source block (mask) does not have a parameter named 'Peak amplitude' Do you know the correct name to this parameter? Thanks a lot for the help that you can bring me....
@user-zf7kh1gs4f
@user-zf7kh1gs4f 3 года назад
非常感谢您的视频
@ProgrammerWorld
@ProgrammerWorld 3 года назад
别客气 Cheers Programmer World programmerworld.co -
@TudorMiron
@TudorMiron Год назад
I'd like to ask a question. I created a complex multibody vehicle model in simulink. It outputs lots of data (via to Workspace) and initially I was analyzing results in MatLab. Now I want to build an App to interact with the model - vehicle setup adjustments etc. I read the results from MatLab to app via evalin command (x_parameter=evalin('base','Res.Chassis.F_Axle.etc, etc. Res. being simout timeseries with simulation results). All worked fine till I decided that I want to add a simple possibility to run the model from this app. If I initialize/run the model from App than it doesn't write the results to base workspace. If I would run it from Simulink - than it does, from App it doesn't... May be this is the way it should be but than how do I access results considering that it's a large amount of channels?
@user-or8xb6vy3k
@user-or8xb6vy3k Год назад
same problem
@ProgrammerWorld
@ProgrammerWorld Год назад
When you run the Simulink model from the App then by default all the data gets output to function workspace and not base workspace. To access the data, you would have to use "caller" parameter instead of "base" in your evalin command. (x_parameter=evalin('caller', Res.Chassis.F_Axle') Other option is to use ASSIGNIN command to transfer the data from function to base worksapce. assignin('base', 'Res.Chassis.F_Axle', Res.Chassis.F_Axle_base) Hope above helps. Cheers Programmer World programmerworld.co -
@TudorMiron
@TudorMiron Год назад
@@ProgrammerWorld Many thanks for your reply! I will be able to try it out in a couple of days and will report here. Thank you!
@yasonthayanithi6372
@yasonthayanithi6372 2 года назад
Hello, I am keep getting this error - Unrecognized field name "Time". & Dot indexing is not supported for variables of this type. What is the reason? I am using R2021b.
@josephnkulenu186
@josephnkulenu186 Год назад
Same issue here.Can you help please?
@devikamahajan4365
@devikamahajan4365 3 года назад
Hi, I would like to know if its possible to run an App designed in App designer which is running in one session of matlab and simulink model is running in 2nd session of matlab. I want to form a communication link between the two. Could you please help me.
@ProgrammerWorld
@ProgrammerWorld 3 года назад
To communicate between 2 different sessions of Matlab, you will have to build some kind of communication channel between the two based on IP protocol. It can be done using Java class for communication. Cheers Programmer World programmerworld.co -
@angelleal3005
@angelleal3005 2 года назад
Can the app designer be used for real time sensor readings ?
@ayushvarun1425
@ayushvarun1425 Год назад
will the plot function work for live graphs(i mean the graphs which takes time to get plotted in simulink model)....plzzz reply
@ProgrammerWorld
@ProgrammerWorld Год назад
No, in progress simulation data cannot be plotted in the App designer, because in the below "simout" will get the values once the simulation is finished: simout = sim(‘SineWave_SL’, ‘StopTime’, num2str(app.DurationSlider.Value)); Which is further used to plot using the below command: plot(app.UIAxes, simout.SineWaveValue.Time, simout.SineWaveValue.Data); For reference, details shown in this video is also shared in the below link: programmerworld.co/matlab/simulate-a-model-through-app-designer-set-parameters-and-plot-outputs-in-app-designer/ Cheers Programmer World programmerworld.co -
@ayushvarun1425
@ayushvarun1425 Год назад
@@ProgrammerWorld so do u mean I will get the plot on the app designer only after the graph is completed in the scope block(it takes around 800 sec for the simulation to complete )??? Plzzz reply I really need help
@ProgrammerWorld
@ProgrammerWorld Год назад
Yes, plot will come in app designer after the simulation completes. Cheers Programmer World programmerworld.co -
@sunilgiri7718
@sunilgiri7718 4 года назад
Hi, Can you please suggest me the way to display the Organization Logo in the MATLAB App designer window. Let's say for an instance, I have developed a GUI for Integrated Simulink Environment with App designer and as soon as I click on Start button, my output figures and other results appear in the App designer window. So along with that I want to display the logo as well. P.S - I know this can be done easily by using the release R2018b and onwards, But I am using MATLAB R2017b version. Thanking you in Anticipation.
@ProgrammerWorld
@ProgrammerWorld 4 года назад
I think you can simply use image button to show the image in your App developed in App designer in R2017b. Please refer to my below video for the same: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-3IQMZQ7JBn0.html Good Luck Programmer World programmerworld.co -
@sunilgiri7718
@sunilgiri7718 4 года назад
@@ProgrammerWorld - Thank you so much, I didn't know this could be done so easily. Keep uploading nice and informative videos on such topics. 👍👍
@adarshmishra6379
@adarshmishra6379 6 лет назад
I want to create a BUTTON on GUI, so that when I click on it some new buttons, texts and plots appears (which were not displaying earlier when I had not clicked on that BUTTON). How can I do this?
@ProgrammerWorld
@ProgrammerWorld 6 лет назад
This can be done easily. You will have to change the visibility flag of the buttons you want to control in the callback functionality.
@adarshmishra6379
@adarshmishra6379 6 лет назад
Programmer World thanks!
@aykutsirma4260
@aykutsirma4260 3 года назад
Nice information. Is it possible to show us a real time plotting in the graph too please? For example, we get serial data from arduino - serial port and plot it in real time with App Designer? thank you.
@ProgrammerWorld
@ProgrammerWorld 3 года назад
I do not have a video on Arduino as of now. However, in my below video it shows how to capture live video from the webcam and display it in the App Designers. You may refer to it: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-xp3KtoWaGX8.html Cheers Programmer World programmerworld.co -
@aykutsirma4260
@aykutsirma4260 3 года назад
@@ProgrammerWorld friend, I have more question. I have an AXES component graph, and I want to change its x or y axis' maximum value with slider component which when I change the slider value then graph's x or y axis maximum value will be changed too. How can we apply such feature? app.UIAxes.XLim = [0 app.hx711yAxisSlider.Value]; I write this line of code but on the App Designer GUI, when I change the slider value - the x axis maximum value is not changing, which it is not updating. I will be very glad if you would guide me, thank you very much.
@vincevenice1333
@vincevenice1333 4 года назад
Hey I just wanted to know that can we use external button to start any program in app designer? Thank you for your help
@ProgrammerWorld
@ProgrammerWorld 4 года назад
Yes, why not ... Just in the call back method of the button put the right API to be called. Good Luck Programmer World programmerworld.co -
@vincevenice1333
@vincevenice1333 4 года назад
@@ProgrammerWorld Thank you for your reply But in the button call back either the value is for changed or changing of the button but I want to change the state by pressing external button. Do I need to put the API for that?
@rolanossi3275
@rolanossi3275 3 года назад
let me thank you for this useful explanation. But when I tried to convert it to an.exe application using Standalone app, the generated software was not plotting the data. Any idea sir?
@ProgrammerWorld
@ProgrammerWorld 3 года назад
This App Designer GUI uses a Simulink model to simulate and plot the data. So, I am not sure, but please check if the model file (.slx file) is included while creating the .exe application. If the model file is not available then the App will not be able to plot as it will not get the data. I hope above clarifies and helps. Just for reference, the complete code shown in this tutorial is also shared in the below page: programmerworld.co/matlab/simulate-a-model-through-app-designer-set-parameters-and-plot-outputs-in-app-designer/ Cheers Programmer World programmerworld.co -
@SanjeevKumar-ib7ei
@SanjeevKumar-ib7ei 5 лет назад
Nicely explained!! Sir, is there any way to change amplitude/frequency in run time...??
@ProgrammerWorld
@ProgrammerWorld 5 лет назад
Parameters values such as amplitude or frequency can be set in the workspace or sim command. However, once set the values cannot be changed for the simulation in progress. So, in order to change the parameter values, you may have to stop any previously running simulation and restart the sim command with updated values. I hope this answers your question.
@SanjeevKumar-ib7ei
@SanjeevKumar-ib7ei 5 лет назад
@@ProgrammerWorld Thanks for prompt response!! It clarified my doubt and what I understood that we can't send /receive parameters while model is running. If you found any way to do this plzz let me know.
@adrianivanov6626
@adrianivanov6626 5 лет назад
Is there any way that i can design a GUI that uses a model generated by Regression Learner app to make predictions using data the user inputs in the GUI? I tried using the modelname.predictFcn() function in Appdesigner code but, since I am a beginner, I can't seem to make it work.
@ProgrammerWorld
@ProgrammerWorld 5 лет назад
Hi, There should be no reason for your predictFcn command to not work in the App designer code. Of course I assume you have the necessary toolboxes 'Statistics and Machine Learning Toolbox' installed on your machine. Now, if you could have provided the error message you are observing then it would have helped to evaluate the reason behind the failure. However, one reason could be the variables are not present in the App workspace. To explain it further, let's assume you have created your trained model in the base workspace of matlab and trying to access the same from the App code then it won't work as the variable is not present in the App workspace. You will have to use ASSIGNIN or EVALIN command to do the respective adaptation of the workspace variables. If above does not helps to resolve your query then please copy the error message here. Then probably I can evaluate it better.
@adrianivanov6626
@adrianivanov6626 5 лет назад
@@ProgrammerWorld This is the error message: Undefined variable "modelh2s" or class "modelh2s.predictFcn". I suppose you are right about using ASSIGNIN or EVALIN, but I am not smart enough to use them. Could you help me a bit more with explaining which one to use and how? I have read the syntax for both these commands, but I find them confusing.
@ProgrammerWorld
@ProgrammerWorld 5 лет назад
From the error message it is very clear that the issue is that the variable is not present in the App Designer workspace. I assume you created your predictive model in the base workspace, so the variable "modelh2s" exists only in base workspace. To access the variable from the base workspace into your local (App Workspace), you can use the below command. This should create a variable "modelApp" in the local workspace. modelApp = evalin('base', 'modelh2s'); I hope the above helps you in resolving your issue.
@adrianivanov6626
@adrianivanov6626 5 лет назад
@@ProgrammerWorld In my country we have a saying: when you're stupid, life is also hard. I have been trying to get my head around this for a few days now. Thank you for making my life a little easier. I ended up using evalin to create the modelApp with a struct insted of a function. Works perfectly!! This is the piece of code i wrote: function ButtonPushed(app, event) modelApp=evalin('base','modelPredictieh2s'); a=app.amineEditField.Value; b=app.swsEditField.Value; array2table(a); array2table(b); c=horzcat(a, b); d = modelApp.predictFcn(c); app.rezEditField.Value = d; end Thank you so much!
@adrianivanov6626
@adrianivanov6626 5 лет назад
@@ProgrammerWorld Here I am, returning to you. After using evalin with success, I have tried compiling my app as a standalone. The GUI loads, but the calculation does not. I am guessing it is because evalin? Is there any otherway to load the .mat file I need into the code so that it works in standalone version? I have tried to make a simpler GUI and deploy it as standalone and it worked, so there is no problem with the compiler
@siddheshr7885
@siddheshr7885 5 лет назад
Excellent Video !! I am trying to display video in GUI, can you tell how to do it?
@ProgrammerWorld
@ProgrammerWorld 5 лет назад
Please watch my below video. In this it is shown how to get webcam video in gui using Matlab app designer. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-xp3KtoWaGX8.html
@sarthakrawat655
@sarthakrawat655 5 лет назад
Can we create a pushbutton to browse .Data file or upload excel sheet and it as an input to simulink to simulate ?? Please help me on this
@ProgrammerWorld
@ProgrammerWorld 5 лет назад
You can do this easily by using XLSREAD command for getting data from excel sheet. For other files you can use fopen, fscanf, fgets, fread, etc command to browse the data. Use above command in the callback of your pushbutton. Extract the data in some local variable. And then use this local variable to pass the input to the Simulink model. You can exchange the data through base workspace using the assignin command as shown in my video presentation. And of course you can simuate your model from your gui using sim which is also shown in the video presentation.
@sarthakrawat655
@sarthakrawat655 5 лет назад
@@ProgrammerWorld Thanks a lot sir your video helped me alot Also I want to ask if there is any other way to hide a plot after pushing a button I used app.plot.Visible='Off' It worked the axes were hidden but the plot was still visible I cannot hide the plot
@ProgrammerWorld
@ProgrammerWorld 5 лет назад
I think what you are looking here is 'cla' command. So, calling cla(app.UIAxes) should clean up your axes with any plots your have drawn on it. Then you can call your app.UIAxes.Visible='off' to hide the axes itself. Good Luck PW!
@sarthakrawat655
@sarthakrawat655 5 лет назад
Thanks alot
@sarthakrawat655
@sarthakrawat655 5 лет назад
@@ProgrammerWorld sir I tried but I couldn't do it If it's possible could you please make a video on this topic??
@abhijeetkibe5901
@abhijeetkibe5901 4 года назад
Hello sir excellent video, can you please help me...I want to translate( in x,y,z) 3d geometries using GUI of app designer...
@ProgrammerWorld
@ProgrammerWorld 4 года назад
Can you please be a bit more specific? You want to translate the the coordinates in to what object? Anything which can be done in Matlab script can be done in App designer. So, details will help me to understand your objective here. Cheers Programmer World programmerworld.co -
@darshankannur3682
@darshankannur3682 4 года назад
Sir please tell me how to change input parameters in simulink through app designer only.. ?
@ProgrammerWorld
@ProgrammerWorld 4 года назад
An example of changing parameters from App designer is shown in this video. Check line number 18 of my code. The amplitude value of sine wave is set in the App designer which is used in Simulink model.
@darshankannur3682
@darshankannur3682 4 года назад
@@ProgrammerWorld Thank you so much sir. Sir please make a video on making a app standalone when the app is depending on simulink file and simulink is depending on excel sheet connected to it.
@ProgrammerWorld
@ProgrammerWorld 4 года назад
@@darshankannur3682 Hi, In this video it very nicely shows the interaction between App designer and Simulink model. It gives inputs to the Simulink from App designer and displays the output of Simulink model in App designer. However, if you want to have an interaction or dependency with the Excel sheet, then you can refer to my below videos. In the below video it shows how you can enable traceability between the Excel sheet and Simulink model: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-74T8RWyIbPs.html In the below video it shows how you can export the Simulink data to an Excel sheet: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-P6LycAJmw3M.html Hope above helps. Cheers Programmer World programmerworld.co -
@darshankannur3682
@darshankannur3682 4 года назад
@@ProgrammerWorld yeah sir I have already did the excel part using from spreadsheet block. But Sir I want to know how make an app stand alone desktop app. When it is in interface with simulink and excel. I tried but app is not running. I think I have missed links and files. Can u please make a video on that.. Thank you in advance. ☺
@ProgrammerWorld
@ProgrammerWorld 4 года назад
@@darshankannur3682 OK, thanks for detailed input. So, basically the requirement is to have a standalone desktop application which can interact with an excel sheet and Simulink model. I will try to make a tutorial on above topic and will let you know once I post it. Thanks again. Cheers Programmer World programmerworld.co -
@ouafaeer-rachedy8078
@ouafaeer-rachedy8078 2 года назад
how can I define stop time in inf
@ProgrammerWorld
@ProgrammerWorld 2 года назад
Below will work: simout = sim('SineWave_SL', 'StopTime', 'inf'); Also, simulating the model just with the model name as in below will take the stop time from the configuration of the model. simout = sim('SineWave_SL') So, if in the model configuration the simulation time is set to inf, the model will simulate to infinity. Please note: when simulating a model with infinite stop time, to stop the simulation, you must press Ctrl+C. Ctrl+C breaks the simulation, however, the simulation results are not saved in the MATLAB workspace. For reference, the complete source code shown in this video is also shared in the below link: programmerworld.co/matlab/simulate-a-model-through-app-designer-set-parameters-and-plot-outputs-in-app-designer/ Cheers Programmer World programmerworld.co -
@ouafaeer-rachedy8078
@ouafaeer-rachedy8078 2 года назад
@@ProgrammerWorld thank u so much
@ouafaeer-rachedy8078
@ouafaeer-rachedy8078 2 года назад
I need to plot more than out how can I do it because i try it but i have a errour: data cannot have more than 2 dimentions
@ProgrammerWorld
@ProgrammerWorld 2 года назад
@@ouafaeer-rachedy8078 You can use plot3 for plotting 3 dimensional points. Cheers Programmer World programmerworld.co -
@suba.2850
@suba.2850 10 месяцев назад
thank you so much sir. i have question. can i email you?
@ProgrammerWorld
@ProgrammerWorld 10 месяцев назад
For any questions, suggestions or appreciation please contact us at: programmerworld.co/contact/ or email at: programmerworld1990@gmail.com
@ayushvarun1425
@ayushvarun1425 Год назад
does set_param function do the same function as assignin function ....if no,can u plz provide the code for the same simulink model using set_param function....plzz reply to this
@ProgrammerWorld
@ProgrammerWorld Год назад
No set_param and assignin are different functions. Instead of this: assignin(‘base’,’Ampl’,app.AmplitudeSlider.Value); You can try this: set_param('SineWave_SL', 'Ampl', app.AmplitudeSlider.Value) It should work. For reference, details shown in this video is also shared in the below link: programmerworld.co/matlab/simulate-a-model-through-app-designer-set-parameters-and-plot-outputs-in-app-designer/ Cheers Programmer World programmerworld.co -
Далее
How to Build a GUI in MATLAB using App Designer
10:26
Просмотров 189 тыс.
App Design in MATLAB
54:04
Просмотров 20 тыс.
😭Телеграм УДАЛЯЮТ❌
00:50
Просмотров 130 тыс.
娜美这是在浪费食物 #路飞#海贼王
00:20
App Designer for Beginners | @MATLABHelper Blog
11:33
6 UI Hacks I Wish I Knew As A Beginner
11:11
Просмотров 790 тыс.
These Coding Projects Give You An Unfair Advantage
14:39
Building MATLAB Apps with App Designer
28:31
Просмотров 97 тыс.
😭Телеграм УДАЛЯЮТ❌
00:50
Просмотров 130 тыс.