I am working on translating some old fortran code into MATLAB and have run across the following issue.
In the fortran file I am working with the following check is performed
CHARACTER*72 PICTFILECHARACTER*8192 INLINEINTEGER NPXINTEGER NLNINTEGER BYTESc This is read from another file but I'll just hard code it for nowNPX = 1024NLN = 1024bytes=2open(unit=10, file=pictfile, access='direct', recl=2*npx, status='old')read(10,rec=nln, err=20) inline(1:2*npx)go to 2120 bytes=121 continueclose(unit=10)
where nln is the number of lines in the file being read, and npx is the number of integers contained in each line. This check basically determines whether each of those integers is 1 byte or 2 bytes by trying to read in a line of 2 bytes for each integer, and then adjusting to 1 byte if there is an error. I understand the fortran code well enough to figure that out, but now I need to figure out how to perform this check in MATLAB. I have tried using the fgetl command on the file and then reading the length of the characters contained but the length never seems to be more than 4 or 5 characters, when even if each integer is 1 byte the length should be somewhere around 1000.
Can someone help me with devising some way to perform this check in MATLAB? I've thought about maybe a try-catch statement but I'm not very familiar with them and don't really know where to start.