MATLAB Answers

0

How to use uigetfile to open subfolder's file.

Asked by han han on 15 Nov 2019 at 2:09
Latest activity Commented on by han han on 15 Nov 2019 at 2:17
How to use uigetfile to open the .txt in the subfolder.
Or there are other ways to use this.
[file,filepath] = uigetfile('*.txt');
WISETEST = fopen( file, 'rt');
out = textscan(WISETEST, '%s', 'Delimiter',{' '});
aa = out{1}(1:end)';
it seems to only open the .txt in the current directory.

  0 Comments

Sign in to comment.

1 Answer

Answer by Walter Roberson
on 15 Nov 2019 at 2:14
 Accepted Answer

[file,filepath] = uigetfile('*.txt');
if isempty(file); return; end %user cancel
fullname = fullfile(filepath, file);
WISETEST = fopen( fullname, 'rt');
out = textscan(WISETEST, '%s', 'Delimiter',{' '});
fclose(WISETEST);
aa = out{1}(1:end)';

  1 Comment

THX!

Sign in to comment.