Error: Unable to resolve the name load.MATLABDriveTag

4 vues (au cours des 30 derniers jours)
Rita Barnabé
Rita Barnabé le 2 Nov 2021
Réponse apportée : Vidip le 21 Fév 2024
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 ])

Réponses (1)

Vidip
Vidip le 21 Fév 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:

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Tags

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by