Clear Filters
Clear Filters

Using evalin to read .m script

1 view (last 30 days)
James
James on 17 May 2013
I have a .m script already written that reads text files as input. I'm writing a GUI in GUIDE and I want to use a push button to get the values from my .m script. I am assuming that the evalin function is the correct route to go here. But I am unsure exactly how to use it. I am relatively new to MATLAB. How do I store the values from the .m script in 'base' and then call those values from my GUI? Thanks in advance!

Accepted Answer

Image Analyst
Image Analyst on 17 May 2013
Edited: Image Analyst on 17 May 2013
evalin() is not the correct route, or at least not the preferred route. Just put a button on your GUI, view the callback, and paste the code from your m-file into the button's callback. That's what I'd do if the m-file is small enough.
If it's a really long complicated m-file, then I'd just make it a function that returns one of more variables that you can accept when you call it from your button's callback. Like in the callback
[out1, out2, out3] = my_m_file(in1, in2);

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!