Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
fopen(machineformat=vaxd)

Subject: fopen(machineformat=vaxd)

From: Jan Simon

Date: 18 Oct, 2008 12:39:02

Message: 1 of 8

Dear users!

I used the following command in Matlab 6.5 to open a file in Vax-D format:
  FID = fopen(FileName, Permission, 'd')

This fails in Matlab R2008b, because the list of known machineformats has been reduced.

1. When did this happen?
2. I've tried a lot of searching on www.mathworks.com without success - what a the right terms for searching?
3. How do I read the files written in VAXD format?

Thanks, Jan

Subject: fopen(machineformat=vaxd)

From: James Tursa

Date: 18 Oct, 2008 17:41:02

Message: 2 of 8

"Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de> wrote in message <gdcld5$2jj$1@fred.mathworks.com>...
> Dear users!
>
> I used the following command in Matlab 6.5 to open a file in Vax-D format:
> FID = fopen(FileName, Permission, 'd')
>
> This fails in Matlab R2008b, because the list of known machineformats has been reduced.
>
> 1. When did this happen?
> 2. I've tried a lot of searching on www.mathworks.com without success - what a the right terms for searching?
> 3. How do I read the files written in VAXD format?
>
> Thanks, Jan

I may be able to write some custom code for you ... I just did something similar on another newsgroup thread recently. Is the file just a pure binary file with only D-FLOAT numbers? How many per record? What system are you reading these on? Do you know if your system is big-endian or little-endian?

James Tursa

Subject: fopen(machineformat=vaxd)

From: James Tursa

Date: 18 Oct, 2008 22:21:01

Message: 3 of 8

> "Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de> wrote in message <gdcld5$2jj$1@fred.mathworks.com>...
> > Dear users!
> >
> > I used the following command in Matlab 6.5 to open a file in Vax-D format:
> > FID = fopen(FileName, Permission, 'd')
> >
> > This fails in Matlab R2008b, because the list of known machineformats has been reduced.
> >
> > 1. When did this happen?

FYI, it was available in 2008a (along with VAXG), but was dropped from 2008b for some reason.
 
 James Tursa

Subject: fopen(machineformat=vaxd)

From: Jan Simon

Date: 18 Oct, 2008 23:06:01

Message: 4 of 8

Thanks James!
 
> I may be able to write some custom code for you ... I just did something similar on another newsgroup thread recently. Is the file just a pure binary file with only D-FLOAT numbers? How many per record? What system are you reading these on? Do you know if your system is big-endian or little-endian?

It would be a big hack! I'm working with C3D files, which contain a section with mixed CHAR, INT8, UINT16, FLOAT32.
Afterwards a big block of binary records is following and finally **any** kind of supplemental data are allowed.

I have about trial 20.000 files and assume 20% of them use the VaxD format.

I'm enormously surprised that Matlab has removed this important feature from FOPEN! It worked since Matlab 4 (or even earlier), you find the VAXD-Format in Octave and Scilab. Unfortunately, I cannot find any documentation for this loss of features on the Mathworks web docs. By the way, where do I find the documentation for former releases?

So the best solution for me would be a conversion in 6.5.1: Read in VAXD and develop a function to write in little-endian. That's no fun.

Kind regards, Jan

Subject: fopen(machineformat=vaxd)

From: Jan Simon

Date: 18 Oct, 2008 23:34:01

Message: 5 of 8

Google found out, that R2007 had the VAXD format for FOPEN.
Python use it also.
Waiting for ideas, Jan

Subject: fopen(machineformat=vaxd)

From: James Tursa

Date: 19 Oct, 2008 15:59:47

Message: 6 of 8

On Sat, 18 Oct 2008 23:06:01 +0000 (UTC), "Jan Simon"
<matlab.THIS_YEAR@nMINUSsimon.de> wrote:

>Thanks James!
>
>> I may be able to write some custom code for you ... I just did something similar on another newsgroup thread recently. Is the file just a pure binary file with only D-FLOAT numbers? How many per record? What system are you reading these on? Do you know if your system is big-endian or little-endian?
>
>It would be a big hack!

I don't think so. At least not based on what you have written so far.

>I'm working with C3D files, which contain a section with mixed CHAR, INT8, UINT16, FLOAT32.
>Afterwards a big block of binary records is following and finally **any** kind of supplemental data are allowed.
>

I am assuming you can still open and read the files, and most of the
data (i.e., the CHAR, INT8, etc.) still reads in OK as long as you get
the endian stuff correct. It sounds like your only real problem is the
VAXD floating point format. My strategy would be to simply read these
values in as double, int64, or uint64 bit patterns, and then write a
little conversion function.

I notice you have FLOAT32 above. This would be a single precision
F_FLOAT format, not a double precision D_FLOAT format. Are you reading
in single precision 32-bit floating point numbers, or double precision
64-bit floating point numbers? F_FLOAT numbers are actually easy to
convert to IEEE single once you get the endian correct ... just divide
what you read in by 4.

>I have about trial 20.000 files and assume 20% of them use the VaxD format.
>
>I'm enormously surprised that Matlab has removed this important feature from FOPEN! It worked since Matlab 4 (or even earlier), you find the VAXD-Format in Octave and Scilab.

Curious. Why would they delete a capability? I don't know.

> Unfortunately, I cannot find any documentation for this loss of features on the Mathworks web docs. By the way, where do I find the documentation for former releases?
>

I don't believe The Mathworks has any documentation online for former
releases, unfortunately.

>So the best solution for me would be a conversion in 6.5.1: Read in VAXD and develop a function to write in little-endian. That's no fun.
>

Actually, the endian stuff is easy ... just do some byte swapping. It
is the conversion of VAXD (8 bit exponent, 55 bit mantissa) to IEEE
double (11 bit exponent, 52 bit mantissa) that is a bit tricky (mostly
the rounding), but I don't think it would be too difficult.

James Tursa

Subject: Simulink

From: Aung Shane

Date: 19 Oct, 2008 16:28:44

Message: 7 of 8

Hi Users,

I have some difficulties (1)using FFTScope to view the power spectral denisty of my signal. I am seeing the high dB value (2) not able to generate high frequency noise somewhere around 200kHz. Tried generate using the noise generator in the simulink but not working. Pls kindly help me on this.

With Regards

Subject: fopen(machineformat=vaxd)

From: James Tursa

Date: 20 Oct, 2008 01:11:01

Message: 8 of 8

"Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de> wrote in message <gddq4p$k2t$1@fred.mathworks.com>...
> Thanks James!
>
> > I may be able to write some custom code for you ... I just did something similar on another newsgroup thread recently. Is the file just a pure binary file with only D-FLOAT numbers? How many per record? What system are you reading these on? Do you know if your system is big-endian or little-endian?
>
> It would be a big hack!

I don't think so. At least not based on what you have written so far. Like I wrote earlier, I have already done something very similar quite recently.

> I'm working with C3D files, which contain a section with mixed CHAR, INT8, UINT16, FLOAT32.
> Afterwards a big block of binary records is following and finally **any** kind of supplemental data are allowed.
>

The only problem you seem to have is the D-FLOAT stuff.
All of the other variables I assume you can still read
in OK, as long as you get the endian convention OK.
The strategy I am proposing is to pick the appropriate
endian for fopen, then read in the data using fread.
The D-FLOAT stuff will of course read incorrectly as
an IEEE double, but I can write a function to manipulate
the bits after you read in the value to convert them
from a D-FLOAT format to an IEEE double format. I am
quite familiar with both and this should not be too
difficult. D-FLOAT only has 8 bits for exponent and
55 bits for mantissa, whereas IEEE double has 11 bits
for exponent and 52 bits for mantissa. The range of
a D-FLOAT is less than a IEEE double, so the only tricky
part will be the rounding from 55 bit mantissa down
to a 52 bit mantissa. If MATLAB somehow screws up the
floating point bits on the fread operation so you don't
get the exact bit pattern on the fread, you could always
read them in as int64 or uint64 and then do the bit
conversion on that instead.

Alternatively, you could read in the file in native format, and then use swapbytes to do the endian stuff manually.

Just to be clear, D-FLOAT is a 64-bit double precision floating point format, whereas F-FLOAT is a 32-bit single precision floating point format. You wrote FLOAT32 above. Was this what you are assuming is D-FLOAT?

> I have about trial 20.000 files and assume 20% of them use the VaxD format.
>
> I'm enormously surprised that Matlab has removed this important feature from FOPEN! It worked since Matlab 4 (or even earlier), you find the VAXD-Format in Octave and Scilab. Unfortunately, I cannot find any documentation for this loss of features on the Mathworks web docs.

Yes, this is a bit surprising. Since they already had this capability, why give it up? I am not familiar with Octave or Scilab. Are they easy to install & run so I can generate some test files on my own?

> By the way, where do I find the documentation for former releases?
>

I don't think they maintain documentation for past releases on their website.
 
> So the best solution for me would be a conversion in 6.5.1: Read in VAXD and develop a function to write in little-endian. That's no fun.
>

The endian part is the easy part.

James Tursa

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us