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

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?

 Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 23 de Nov. de 2020
directory='c:\myfolder';
filename='myfile.xlsx';
readtable(fullfile(directory,filename));

Más respuestas (0)

Categorías

Más información sobre Search Path en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 23 de Nov. de 2020

Comentada:

el 23 de Nov. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by