フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

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

1 回表示 (過去 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