Can one define a "directory" as a "variable"?

조회 수: 1 (최근 30일)
alpedhuez
alpedhuez 2020년 11월 23일
댓글: alpedhuez 2020년 11월 23일
Suppose I want to use readtable to read a file. I understand the format
readtable('C:\myFolder\myFile.xlsx')
readtable('C:\myFolder\myFile2.xlsx')
But in my case such directory name is very long and it is cumbersome that I need to specify that long directory name each time. Is it possible to define a directory name as a variable and simplify the process?

채택된 답변

Fangjun Jiang
Fangjun Jiang 2020년 11월 23일
directory='c:\myfolder';
filename='myfile.xlsx';
readtable(fullfile(directory,filename));

추가 답변 (0개)

카테고리

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