Converting VAX float to Matlab float
Show older comments
Hello,
I am working on a script that needs to read in a binary file containing VAX floats/doubles. Matlab used to have a machine format for FOPEN to cover that kind of conversion, but it is no longer supported.
Is there any workaround or replacement? I checked the docs for VAX/VMS, but came up with nothing :(
Thanks.
Answers (2)
Fangjun Jiang
on 17 Aug 2011
what do you mean, I saw fopen() has the option for 'vaxd'.
All right,
fopen No Longer Supports VAXD, VAXG, and Cray Machine Formats
Calls to fopen with any of the following values for machine format return an error:
* 'vaxd' or 'd'
* 'vaxg' or 'g'
* 'cray' or 'c'
Compatibility Considerations
In previous releases, calls to fopen with machine format values associated with VAXD, VAXG, and Cray did not result in an error.
To read files in VAXD and VAXG formats, consider the workaround available on the MATLAB Central File Exchange, file ID #22675.
Jan
on 17 Aug 2011
0 votes
There are some solutions in the FEX:
- http://www.mathworks.com/matlabcentral/fileexchange/22675
- http://www.mathworks.com/matlabcentral/fileexchange/24793
- http://www.mathworks.com/matlabcentral/fileexchange/22675-read-vaxd-and-vaxg-files-in-r2008b-and-later
Please test them exhaustively, because there have been some serious bugs in the past. I think the most efficient method would be to read the files by another programming language and convert them to IEEE format.
Please write an enhancement request to TMW if you are suffering from this strange limitation also. Perhaps the VAXD support will be back again, if enough people need this feature.
See also my VAXD related answer in http://www.mathworks.com/matlabcentral/answers/1427-what-frustrates-you-about-matlab. I'm looking forward to James' submission.
2 Comments
James Tursa
on 17 Aug 2011
Yikes! I am embarassed to admit that I forgot all about this because I have been currently working on updates to my MTIMESX submission (in-place operations, matrix versions of prod and cumprod) and Fortran 95 Interface submission (64-bit support and a few enhancements).
For the VAXD and VAXG stuff, basically I have overloaded fopen, fclose, fread, and fwrite routines that look for VAXD, VAXG, etc arguments, pick them off and tag the file as VAXD (or VAXG) then pass all the other arguments through to the builtin fopen etc routines. Then whenever you call fread or fwrite for a VAXD or VAXG tagged file they automatically convert the bit patterns for you in the background. Bottom Line: All of your old code that uses VAXD or VAXG options will work without modification in newer versions of MATLAB that have no native VAXD or VAXG support. I have working prototype code for all of this at the moment. I will bump up the priority of this project, polish it up, and try to get an FEX submission out in a few weeks.
Beware of the current online workaround submissions for VAXD and VAXG support, they have bugs that have never been fixed to my knowledge (and they are really messy to use IMO).
Jan
on 17 Aug 2011
@James: When TMW removed the VAX features from FOPEN, a lot of expensive testing must have been necessary. Now you spend time (== money) to make this feature available again. This is such inefficient, that it causes wild emotions in my mind - SUBOPTIMAL!
Categories
Find more on Parallel Computing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!