I want to create a MATLAB gui where I can open file explorer using a pushbutton and select a file for further processing. How can I do that?
Also I want to know how to assign .m function files to the pushbuttons. I tried putting functionname.m file in callback of the pushbutton. But it didn't work.
Please help me with both doubts.
TejashreeTejashree
1 Answer
You'll need to write a callback function to launch the file selection dialog (
uigetfile
)In general if you want to call any
SueverSuever.m
file from within a callback, you'll want to wrap the call to it in an anonymous function55k1313 gold badges5656 silver badges7272 bronze badges
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Not the answer you're looking for? Browse other questions tagged matlabmatlab-guide or ask your own question.
I want open a GUI directly from desktop without opening MATLAB and run it from it. When I right click on the main
MATLAB code
file and select Run
in windows environment, MATLAB starts and after that my GUI automatically runs but I want have this with double clicking on an Icon (shortcut) o desktop. How can I do this? I don't want compile my app.- My GUI contains training neural network so I can't compile it.
21.2k1010 gold badges121121 silver badges168168 bronze badges
user2991243user2991243Matlab Open File
1,42866 gold badges3131 silver badges7373 bronze badges
1 Answer
What you actually need is a way to run
.m
files via the command line - an action which isn't specific to GUIs. A command line operation is something you can bind to a shortcut on your desktop or execute using a batch file.The solution you're looking for is a combination of MATLAB-specific syntax and a straightforward batch file creation procedure:
- Open a text editor.
- Write this inside:
'C:<path to your MATLAB folder>matlab.exe' -nodisplay -nosplash -nodesktop -r 'cd('C:<path to your where the .m file is>'); run('C:<path to where the .m file is>mfile.m');'
- Save the file as
.bat
(in windows) and run.
Community♦
Dev-iLDev-iL18.9k66 gold badges4545 silver badges7979 bronze badges
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Not the answer you're looking for? Browse other questions tagged matlabuser-interfaceshortcut or ask your own question.
I am trying to run a MATLAB GUI I have created. If I open the .fig file using GUIDE and press the run button there, it runs perfectly.
However, when I double-click the .fig file in the 'Current Folder' section of MATLAB, it seems to be unable to find the
handles
variable. This causes it to give an error whenever handles
is used.Why does this happen? Is there a fix/workaround?
Windows 10 update orchestrator service high disk usage. Update Orchestrator Service (UsoSvc) Defaults in Windows 10Manages Windows Updates.
I'm using MATLAB R2011, but I've tried it on R2012 as well. The code runs fine, and displays the GUI fine, but the moment it encounters the
handles
variable, it gives the following error:Attempt to reference field of non-structure array.
shashwatshashwat63311 gold badge99 silver badges2525 bronze badges
2 Answers
When you create a GUI using GUIDE, it should create both a
.fig
file and a .m
file. To run it, you should run the .m
file, rather than double-clicking the .fig
file.The
Sam RobertsSam Roberts.fig
file just contains static information about the layout of the GUI - there is nothing executable in it that would initialise handles
and so on.22.3k11 gold badge3434 silver badges5757 bronze badges
Well, always run
ChethanChethan.m
file if you want to check your code and if you want to edit GUI go through guide command. If you open .fig
file you'll get a file which you can't execute and you can't able to analyze that. corresponding .m
file will have respective functions for your GUI.11333 gold badges55 silver badges1919 bronze badges
Not the answer you're looking for? Browse other questions tagged matlabuser-interfacematlab-figurematlab-guide or ask your own question.
is there a way how to make Matlab open excel files directly in MS Excel? I do not mean just read data, but physically open MS Excel.I have a script that processes some data and saves it into .xlsm. This .xlsm contains auto_open macro which generates a report and saves it into another .xls. I want the process to be as automatic as possible. So far, when the matlab script ends, .xlsm file needs to be open manually. Is it possible to do it via Matlab? (The .m file and .xlsm are in the same folder.)
Tshepang6,3541818 gold badges7474 silver badges114114 bronze badges
MartinMartin
3 Answers
The simplest way to open (but not close) an Excel file is to use WINOPEN:
JonasJonas71.8k99 gold badges127127 silver badges168168 bronze badges
Excel has a powerful COM interface that lets you control it from another application.
Look here for the matlab side of things
And here for an example of putting it all together . . .
or here is another example
learnvstlearnvst9,4011010 gold badges5555 silver badges102102 bronze badges
Yes, it is possible. Matlab can use Excel's Automation interface to do this and similar tasks. The following code loads Excel and then loads a workbook:
You will need to look at Microsoft's documentation for the Excel automation interface to figure out exactly what commands you need to send. Try starting here.I have used this technique to drive Word from Matlab in order to produce a report document, but I have never used Excel this way, so unfortunately I can't help you with the gory details! Essential gta v mods.
MaxMax1,76022 gold badges1414 silver badges1818 bronze badges