import to the workspace a .mat file saved in a folder other than pwd

1 visualización (últimos 30 días)
How can I import a .mat file saved in a folder other than pwd to the workspace?
folder = 'C:\Users\Desktop\folder_test';
file = 'test.mat';

Respuesta aceptada

Stephen23
Stephen23 el 22 de Jul. de 2023
Editada: Stephen23 el 22 de Jul. de 2023
The recommended approach is to use FULLFILE (and to always LOAD into an output variable):
S = load(fullfile(folder,file))
Why do you imagine that this has changed since last time you asked how to define path strings?:

Más respuestas (1)

Bruno Luong
Bruno Luong el 22 de Jul. de 2023
Editada: Bruno Luong el 22 de Jul. de 2023
folder = 'C:\Users\Desktop\folder_test';
file = 'test.mat';
load([folder filesep() file])

Categorías

Más información sobre Filename Construction en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by