Hello guys, i have a push button and I want to laod m-file when I press it, please answer ;)
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Maciej Wroz
el 15 de Oct. de 2015
Comentada: Dennie
el 19 de Oct. de 2015
I make a GUI and I want to add a push button that will load a m-file.
2 comentarios
Walter Roberson
el 15 de Oct. de 2015
Please explain further what you mean by "load" of an m file. Do you mean execute the file, or do you mean upload from somewhere to somewhere else?
Respuesta aceptada
Dennie
el 16 de Oct. de 2015
under the callback of the button in the code of that gui, put something like this:
evalin('base','<your_m_file>')
This will run the m-file and load the variables in the matlab workspace! So not in the GUI workspace. If you want to have the variables in the local workspace of the GUI you can use, after the callback is finished the GUI workspace is deleted, so if you want to keep the values of the mfile in the GUI accessible you have to save them in the global structure (the handles structure by default):
eval('<your_m_file>')
also do not include the .m extension in the name.
2 comentarios
Más respuestas (1)
Maciej Wroz
el 16 de Oct. de 2015
Editada: Maciej Wroz
el 16 de Oct. de 2015
1 comentario
Dennie
el 19 de Oct. de 2015
If I understand you correctly, it seems to me that you start the simulink simulation from the m-file, right ? If the m-file is run by the code in the gui, i suppose that the mistake is in the m-file itself. It could be that you use the wrong command to start the simulation. Try using sim() instead of open() or run(). For better help, you should upload the part of the code that currently does this, or give me some more information on what happens and what you would expect to happen.
Ver también
Categorías
Más información sobre Desktop en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!