Error: Unable to resolve the name load.MATLABDriveTag

6 views (last 30 days)
I'm trying to read multiples files .txt from the folder S1 with this:
clear, close all, clc
path_dados_originais = "C:\Users\35191\MATLAB Drive\Data\Projeto_Processamento\Dados_Sessoes\S1";
path_dados_interpolados = "C:\Users\35191\MATLAB Drive\Data\Projeto_Processamento\Dados_interp";
cd(path_dados_originais)
%Ficheiros a usar:
allfiles = dir;
Nfiles = size(allfiles(3:end,1),1);
for j=1:Nfiles
cd(path_dados_originais)
%Ler os dados
file = allfiles(j+2).name;
eval(['load' file ])
ecg_new = interp(ecg,5);
cd(path_dados_interpolados)
mat_dados = [ecg_new];
eval(['save' file(1:end-4) ' mat_dados'])
end
And i have this error:
Unable to resolve the name load.MATLABDriveTag.
Error in Untitled_interpolar (line 17)
eval(['load' file ])

Answers (1)

Vidip
Vidip on 21 Feb 2024
The error you're encountering is likely due to a misuse of the eval function with the load command in MATLAB. When constructing a command string for eval, you must include spaces and properly format the file name with quotes. In most cases, using the eval function is also less efficient than using other MATLAB functions and language constructs, and the resulting code can be more difficult to read and debug.
Instead, you can directly call the ‘load’ and ‘save’ functions with the appropriate file paths and options. For example, use data = load(file, '-ascii'); to load ASCII text files, ensuring you specify the '-ascii' flag if your .txt files are formatted as such. Also, there's no need to change directories within the loop; you can use the ‘fullfile’ function to create full paths to the files.
For further information, refer to the documentation links below:

Categories

Find more on Data Import and Analysis in Help Center and File Exchange

Tags

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!