How to Open a Folder

조회 수: 127 (최근 30일)
Ghina Alhunaidi
Ghina Alhunaidi 2021년 4월 11일
댓글: Walter Roberson 2021년 4월 12일
Hey.
I need help trying to open a folder on matlab while the code is running. I want the folder to open as a response to the user clicking on the screen. I already have the folder in the same pathway as the overall code, I'm just having trouble with the syntax and general terminology to open a specfic folder.
  댓글 수: 11
Ghina Alhunaidi
Ghina Alhunaidi 2021년 4월 12일
I want it to open the file using its default application
Walter Roberson
Walter Roberson 2021년 4월 12일
[filename,filepath] = uigetfile('*.mov');
if isempty(filename)
%user cancel, handle appropriately here
end
fullname = fullfile(filepath, filename);
open(fullname)
Using path as the name of a variable is not recommended as path controls the MATLAB search path.

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2021년 4월 11일
편집: Jan 2021년 4월 11일
Maybe you want to open a file inside this folder?
function main
myPath = fileparts(mfilename('fullpath')); % Folder of this M-file
Folder = fullfile(myPath, 'NameOfSubfolder'); % Subfolder inside
Data = load(fullfile(Folder, 'YourData.mat')); % A specific file there
...
end

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by