Info

此问题已关闭。 请重新打开它进行编辑或回答。

GUI's use

2 次查看(过去 30 天)
Abbass SAYEGH
Abbass SAYEGH 2020-7-2
关闭: MATLAB Answer Bot 2021-8-20
Hello everyone,
I am there because i work on a project with graphic interface. I need help.
In fact, I need in my interface two buttons, one which allows just to select a file (xlsx, png) without opening it, and a second which allows to open the desired file.
so far i have only one button that selects and opens the file, but i need two in my GUIDE interface
Thank you!

回答(1 个)

Image Analyst
Image Analyst 2020-7-2
Try this
For the first function callback, you can call uigetfile:
% Have user browse for a file, from a specified "starting folder."
% For convenience in browsing, set a starting folder from which to browse.
startingFolder = pwd; % or 'C:\wherever';
if ~isfolder(startingFolder)
% If that folder doesn't exist, just start in the current folder.
startingFolder = pwd;
end
% Get the name of the file that the user wants to use.
defaultFileName = fullfile(startingFolder, '*.*');
[baseFileName, folder] = uigetfile(defaultFileName, 'Select a file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(folder, baseFileName)
For the second function, you can call
winopen(fullFileName);
Attach your .-file and fig-file if you still need more help.

标签

Community Treasure Hunt

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

Start Hunting!

Translated by