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

3 次查看(过去 30 天)
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';

采纳的回答

Stephen23
Stephen23 2023-7-22
编辑:Stephen23 2023-7-22
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?:

更多回答(1 个)

Bruno Luong
Bruno Luong 2023-7-22
编辑:Bruno Luong 2023-7-22
folder = 'C:\Users\Desktop\folder_test';
file = 'test.mat';
load([folder filesep() file])

类别

Help CenterFile Exchange 中查找有关 File Operations 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by