In the GUI in MATLAB, how to change the input of a filename in a function for it to be read
1 view (last 30 days)
Show older comments
I have a question. I’m trying to build a Graphical User Interface (GUI). I wish take a file and from there automatically read the file. In doing so, I manage to get the file by using the coding below.
[filename pathname] = uigetfile({'*.txt'},'File Selector');
fullpathname = strcat(pathname, filename);
text = fileread(fullpathname); % Reading information inside a file
set(handles.text2, 'String', fullpathname); % Showing FullPathName
set(handles.text3, 'String', text); % Showing information
The file is in the form such as below :-
aae20110806dmin.min
her20110724dmin.min
iqa20110724dmin.min
When I’m using the coding above, the file can be obtain. It is show in the command window.
The output of the coding is a periodogram being produce. In order for the periodogram to be produce, I have to manually change the file name from the function. The function is such below.
[UT1m,MagDataIAGA] = ReadIAGA1m('fcc20110724dmin.min');
I would like to ask is there a method where I can from the GUI take a file such file
‘ aae20110806dmin.min ‘, and it would be change in the function of the
[UT1m,MagDataIAGA] = ReadIAGA1m('aae20110806dmin.min');
And then when I press the push button in GUI, the periodogram will produce the file of 'aae20110806dmin.min'.
0 Comments
Accepted Answer
Mara
on 18 Jun 2020
From what I understand, your the name 'aae20110806dmin.min' is saved as a string variable called filename.
if you want to use the variable filename in the function that executes when you push the push button, you have to set the variable as a global variable.
Not sure if I understood you right but hope it helps!
% my uigetfile function
global filename
%my pushbutton function
global filename
[UT1m,MagDataIAGA] = ReadIAGA1m(filename);
More Answers (0)
See Also
Categories
Find more on Environment and Settings 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!