Info

此问题已关闭。 请重新打开它进行编辑或回答。

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

2 次查看(过去 30 天)
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