how can i solve the error Reference to non-existent folder

조회 수: 2 (최근 30일)
Gentil Mabote
Gentil Mabote 2021년 9월 9일
댓글: Gentil Mabote 2021년 9월 10일
when i try to call ficheiro the error is Reference to non-existent field 'folder'.
arqdir = 'F:\TCC-GENTIL\New Data';
files = dir(fullfile(arqdir,'*.nc'));
ficheiro=fullfile(files(5),files(5).name);
please can someone explain me how can i solve it?

채택된 답변

Walter Roberson
Walter Roberson 2021년 9월 9일
I suspect that your actual code is
arqdir = 'F:\TCC-GENTIL\New Data';
files = dir(fullfile(arqdir,'*.nc'));
ficheiro=fullfile(files(5).folder,files(5).name);
and I suspect that you are using an older MATLAB release that did not have the folder field . R2016b was the first release that supported that field.
The work-around in this case would be
arqdir = 'F:\TCC-GENTIL\New Data';
files = dir(fullfile(arqdir,'*.nc'));
ficheiro = fullfile(arqdir, files(5).name);

추가 답변 (1개)

Jan
Jan 2021년 9월 9일
편집: Jan 2021년 9월 9일
I guess, that the code is not:
ficheiro = fullfile(files(5), files(5).name);
% but:
ficheiro = fullfile(files(5).folder, files(5).name);
The DIR command of old Matlab versions did not define the field "folder". Which Matlab version are you using?
A workaround is:
arqdir = 'F:\TCC-GENTIL\New Data';
files = dir(fullfile(arqdir, '*.nc'));
ficheiro = fullfile(arqdir, files(5).name);

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by