Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Windows 10 can read my .bin files but Ubuntu cannot?

조회 수: 2 (최근 30일)
Rachel Clark
Rachel Clark 2020년 11월 4일
마감: MATLAB Answer Bot 2021년 8월 20일
I'm running a basic analysis script that requires two .bin files to be read in. On win10 the following works
d1=[];
d2=[];
filenameA= 'Results...A.bin';
filenameB='Results...B.bin';
fid1=fopen(filenameA,'r+');
fid2=fopen(filenameB,'r+');
chunk_size=1e6;
precision='uint64';
d1=fread(fid1,chunk_size,precision);
d2=fread(fid2,chunk_size,precision);
fclose('all');
and reads in the data perfectly fine. On Ubuntu this does not work. d1 and d2 end up just being 0 by 0 arrays. The error doesn't occur until later in the code (when I try to use a size of d1, d2) so I know that it isn't an issue about incorrect filename, working dir, or similar, because the code gets further than this bit. Why would this be an issue? Is it related to file line endings? can this be implemented as an argument with fread?
edit: MATLAB 2019b
  댓글 수: 9
Walter Roberson
Walter Roberson 2020년 11월 5일
Bruno, I am not clear why you indicate that it would fail with 'r+' flag? 'r+' is valid to indicate reading and writing. It does not create the file if it does not exist and it should initially position at beginning of file, but it permits switching to writing in the same file (provided that you fseek each time you switch between reading and writing)
https://www.mathworks.com/help/matlab/ref/fopen.html#btrnibn-1-permission
Bruno Luong
Bruno Luong 2020년 11월 5일
편집: Bruno Luong 2020년 11월 5일
In linux here is what happen if a file opened with 'r+' but doesn't have write permission:
$ touch toto
$ chmod -w toto
$ ls -alrt toto
-r--r--r-- 1 Bruno 197121 0 Nov 5 19:01 toto
MATLAB
>> fid=fopen('toto','r+')
fid =
-1

답변 (0개)

이 질문은 마감되었습니다.

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by