필터 지우기
필터 지우기

Using dir command but the files can not be returned

조회 수: 3 (최근 30일)
Mos_bad
Mos_bad 2018년 3월 8일
편집: Walter Roberson 2018년 3월 8일
After running the code, fileNames1 has not been showing in Workspace (neither name nor value) and there is no error in the first line. However, it gives an error while executing the second line "Undefined function or variable 'numGM'.
code:
FIRST LINE: fileNames1 = dir ('./GMdata/GMsDir/*hc.txt');
SECOND LINE: numGM=length(fileNames1);
  댓글 수: 2
Jan
Jan 2018년 3월 8일
What does "after running the code" mean, if the program stops with an error? Please post the relevant part of the code and a copy of the complete error message.
Mos_bad
Mos_bad 2018년 3월 8일
Undefined function or variable 'numGM'.
Error in PBSS_Bridge_Main (line 196) p_ = randperm(numGM);
It gives me three above lines as the complete error message. I mean, if I run the code ....

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2018년 3월 8일
In line 2 you define
numGM = length(fileNames1)
and in line 196 the variable numGM does not exist anymore. This can have different reasons. Either these are two different functions. Or there is a clear numGM anywhere, or even worse a clear all, perhaps in a called script. Without seeing the relevant code, there is no chance to guess, what happens. But you can examine this in detail using the debugger:
Set a breakpoint in the code and step through the program line by line. Check the existence of the vanishing variable to narrow down, where this happens. The debugger is the programmer's best friend.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by