'.' is not an internal or external command, nor is it a runnable program or batch file

조회 수: 5 (최근 30일)
this below is raw2jpeg.m:
function raw2jpeg(lfp_file)
cd('lfptools') ;
sys_command = ['./lfpsplitter ../' lfp_file];
system(sys_command,'-echo') ;
cd('..') ;
[lfp_folder, lfp_path , ~] = fileparts(lfp_file) ;
lfp_path = [lfp_folder '/' lfp_path] ;
fin = fopen(strcat(lfp_path, '_imageRef0.raw'), 'r') ;
meta = fopen(strcat(lfp_path, '_metadataRef0.txt'), 'r') ;
for i = 1:3
fgets(meta);
end
fgets(meta, 12)
width = fscanf(meta, '%d') ;
fgets(meta) ;
fgets(meta, 12) ;
height = fscanf(meta, '%d') ;
I = fread(fin, width*height, 'uint16=>uint16') ;
im_in = reshape(I, height, width) ;
im_in = im_in' ;
delete([lfp_path '_imageRef0.raw'], [lfp_path '_metadataRef0.txt'], ...
[lfp_path '_privateMetadataRef1.txt'], [lfp_path '_table.txt']) ;
im_in = im_in.*1.5 ;
imwrite(im2uint8(im_in), strcat(lfp_path,'.jpg')) ;
end
The code below is an example for raw2jpeg.m:
raw2jpeg('../input/dataset/raw.lfp'); (just one row)
And the result shows like this:
'.' is not an internal or external command, nor is it a runnable program or batch file
Incorrect use of fgets
The file identifier is invalid. Generate a valid file identifier using fopen (the error exists in line 11 of raw2jpeg.m)
  댓글 수: 2
Bjorn Gustavsson
Bjorn Gustavsson 2019년 9월 16일
What happens if you give the full path to your lfpsplitter program?
Have you tried to run the code line by line? With something like dbstop in raw2jpeg set on the command-line?
Rik
Rik 2019년 9월 16일
It looks like you're getting an error in your system call, which then breaks the assumptions of the later code.

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

답변 (2개)

Guillaume
Guillaume 2019년 9월 16일
First use fullfile to build paths instead of string concatenation and adding the path separator yourself. It would be more reliable.
Ther are many potential failure points in your code and you never check that anything works as you expected, so it shouldn't be surprising that you can get obscure errors.
In the first line of your function, you change to the lfptools directory relative to the current one. If the current directory is not the one you expected or if there's no lfptools directory in the current directory, the cd will fail. Note that there is never any reason to cd anywhere. Using absolute paths guarantees you that the folder you target is the one you meant regardless of what the current directory is.
You then assume that lfpsplitter has run succesfully and created two files with a given name. You never check that it is indeed the case. If it failed or for some reason named the files differently your fopen calls will fail to open the file. As a result the fin or meta file identifier will be invalid and as soon as you try to use it, you'll get an error. This is clearly what is happening here, your meta file identifier is invalid, so the first time you try to use it with fgets you get an error. Most likely the raw_metadataRef0.txt file does not exist (or can't be open for a reason or another).
When dealing with files always check that your operation actually succeeded. After a fopen check the file id is valid (i.e. positive), after a fread check that you've read the number of bytes you expected, etc.
Also, make sure that you call fclose before attempting to delete a file you've been reading/writing to. As it is, your delete call will always fail since you've still got fin and meta open.
  댓글 수: 11
Huadong Hu
Huadong Hu 2019년 9월 17일
the Ifptools folder have files like the picture.QQ图片20190917075828.png,Is it due to the lack of the corresponding file or the code problem?
Guillaume
Guillaume 2019년 9월 17일
Looks like you have the source code for that tool but you haven't compiled it, so of course you can't use it yet.
You'll have to find a compiled version of the tool or compile it yourself. The instructions for compiling it should be in the readme that came with it. Note that this has nothing to do with matlab so if you need help with that you'd be better off finding a support for that tool.

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


Walter Roberson
Walter Roberson 2019년 9월 16일
You are trying to run Linux code on ms windows. You will need to change the / in the system() command to \
  댓글 수: 4
Bjorn Gustavsson
Bjorn Gustavsson 2019년 9월 16일
This should work - is something I ususally find to be a very optimistic aproach to my programming, see Guillaume's answer for detailed description of what to look for.

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

카테고리

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