ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Mathscript: read big-endian & case lists

Hi all,

 

I'm using a MathScript node to read contents from a file. The binary data is stored as big-endian floats, but I only figured out how to read little-endian data.

In Matlab you can specifiy the number formatting when opening a file using fopen. In MathScript I didn't see any option for that, neither in fopen nor in fread. Is there a way to read big-endian floating point data?

 

Second question, I use a switch/case statement. In Matlab I can specify lists of items to match in a case, is there a way to do this in MathScript?

Something like this (a is a string):

switch a

case {'a', 'b'}

...

Thanks,

Daniel

 

 

0 Kudos
Message 1 of 3
(2,939 Views)
Hello Daniel,

Currently the MathScript fopen function does not support the different options to specify reading data in big- or little-endian format.  I will file a bug report to add those options.

When specifying multiple options for a case, the cell array syntax is used.  Currently, MathScript does not support cell arrays.  As a workaround, you can duplicate your cases for each option.

Grant M.
Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments
Message 2 of 3
(2,925 Views)

Hi Grant,

 

Thanks for the information.

That's what I did with the cases, duplicating the options.

Unfortunately I didn't find a suitable workaround for reading big-endian data yet. Probably read as string, shuffle the bytes accordingly and transform into float... I'll have to try.

 

Thanks,

Daniel

 

0 Kudos
Message 3 of 3
(2,920 Views)