From: utab on
On Wed, 16 Jun 2010 11:25:45 -0500, dpb wrote:

>> uhh, the whole story.
>
> Not quite... :)
>
> fid=fopen(????....
> format1 = ????
>
> I think your read lengths are different but w/o "the rest of the
> story"...

Sorry ;) yes there are different lengths here is the portion of the code.

27 %%%%% Open ANSYS Binary file %%%%%
28 [fid,message]=fopen(filename,'r','b');
29 if fid==-1
30 error(message);
31 else
32 str=['ANSYS Binary file ',filename,' opened succesfully'];
33 disp(str);
34 end
38 % Set appropriate format
39 format1='int32'; % integer of 32 bits, or 4 bytes
40 fac1=4; % 4 bytes per integer; fac is used in fseek
command
41 format2='double'; % float of 64 bits, or 8 bytes
42 fac2=8; % 8 bytes per double; fac is used in fseek
command
43
44 % Set 1: Standard ANSYS file header
45 rlength=fread(fid,1,format1); % record length
46 dum=fread(fid,1,format1);
47 ANSYS_file_header=fread(fid,rlength,format1); % read ANSYS file
header
From: dpb on
utab wrote:
> On Wed, 16 Jun 2010 11:25:45 -0500, dpb wrote:
>
>>> uhh, the whole story.
>> Not quite... :)
>>
>> fid=fopen(????....
>> format1 = ????
>>
>> I think your read lengths are different but w/o "the rest of the
>> story"...
>
> Sorry ;) yes there are different lengths here is the portion of the code.
>
> 27 %%%%% Open ANSYS Binary file %%%%%
> 28 [fid,message]=fopen(filename,'r','b');
....

> 38 % Set appropriate format
> 39 format1='int32'; % integer of 32 bits, or 4 bytes
> 40 fac1=4; % 4 bytes per integer; fac is used in fseek
....

I'm no C++ expert, but I think there's your answer -- you told fread to
read 32-bit int's so the platform dependence is handled transparently
whereas in the C code you read individual bytes as they're store on the
medium. Read 32-bit int's there also and all will be well...

--
From: dpb on
dpb wrote:
....

> I'm no C++ expert, but I think there's your answer -- you told fread to
> read 32-bit int's so the platform dependence is handled transparently
> whereas in the C code you read individual bytes as they're store on the
> medium. Read 32-bit int's there also and all will be well...
....
Or, of course, if you set format = 'int8' and tried to concatenate those
byes you'd have to manually swap them around, too, just as in the C code...

--