필터 지우기
필터 지우기

open files from different directorys

조회 수: 1 (최근 30일)
Guilherne
Guilherne 2011년 10월 2일
I have to load data from a .m file to a uitable, thats my code:
diretorio = uigetdir;
filename = uigetfile('*.mat','Select the MATLAB code file');
d = ' \';
e = strtrim(d); % Usado para salvar "/" em forma de string
Dados_1 = strcat(diretorio,e,filename);
Dados_2 = open(Dados_1);
As you can see, its not functional, once i need to ask for the directory name, the file name, then manipulate strings and finally open it. Is there a function that opens files from different directorys?

채택된 답변

Image Analyst
Image Analyst 2011년 10월 2일
Accept BOTH return values from uigetdir(), then combine them with fullfile().
  댓글 수: 5
Guilherne
Guilherne 2011년 10월 9일
Sorry, I didnt understood well when I readed at the first time, I just got that fullfile will help me to put the names together, but didnt realized about the uigetfile. In fact I even dont need the fullfile anymore because I can use the function load to open:
[filename, caminho] = uigetfile('*.mat','Select the MATLAB code file');
Data_1 = load([caminho filename]);
Jan
Jan 2011년 10월 9일
I recommend to use "load(fullfile(caminho filename));" instead. In opposite to the simple concatenation it cares for the necessary file separators.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dialog Boxes에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by