Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

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

1 visualización (últimos 30 días)
Rachel Clark
Rachel Clark el 4 de Nov. de 2020
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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 comentarios
Walter Roberson
Walter Roberson el 5 de Nov. de 2020
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 el 5 de Nov. de 2020
Editada: Bruno Luong el 5 de Nov. de 2020
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

Respuestas (0)

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by