Error: Unable to resolve the name load.MATLABDriveTag

6 ビュー (過去 30 日間)
Rita Barnabé
Rita Barnabé 2021 年 11 月 2 日
回答済み: Vidip 2024 年 2 月 21 日
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 ])

回答 (1 件)

Vidip
Vidip 2024 年 2 月 21 日
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:

カテゴリ

Help Center および File ExchangeData Import and Analysis についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by