Discussion:
How to define "byte stream type" for "open file"?
(too old to reply)
FElicia
2008-08-08 16:10:08 UTC
Permalink
Hello,

I created some numbers (type "double") in Matlab and stored in a file. What value should I use to specify the "byte stream type" for "open file" in Labview? Should I put something like "DBL" or "I32". I don't know where to find the list of legal "types" in Labiew help.

Thanks so much!

Felicia
altenbach
2008-08-08 16:40:05 UTC
Permalink
You would create a diagram constant of the desired type and wire it to the type input of "read binary file". If you don't get a broken wire, it's legal. :D
Since you wrote DBL data, you would read it as DBL. Most likely, you need to also specify little endian.
Can you attach a small sample file and tell us what kind of data you expect?
What is your LabVIEW version? I don't see any "bytestream type" input. If your version is ancient, you might not even have the byte order input.
smercurio_fc
2008-08-08 16:40:06 UTC
Permalink
Looks like 7.1:<img src="Loading Image..."> The Matlab "double" is 64 bits (8 bytes). It doesn't make much sense to use an integer datatype to read a floating point value, so you would use DBL in LabVIEW. The numeric data types table can be found <a href="http://zone.ni.com/reference/en-XX/help/lv/71/lvhelp/Numeric_Data_Types_Table/" target="_blank">here</a>. By the way, this assumes you saved the file as raw binary, as opposed to a .mat file, which is something different. Message Edited by smercurio_fc on 08-08-2008 11:21 AM


read file 7.png:
http://forums.ni.com/attachments/ni/170/347924/1/read file 7.png
FElicia
2008-08-08 19:10:04 UTC
Permalink
Thank both of you!


I'm using Labview 6.1 base "Read File", just like the picture above. I've specified the byte stream type as DBL; however, the output is an array of string. What should I do with the string? I've tried to use "Decimal String To Number" but I got an output of "0".


I've also tried the "Read From SGL File" in Labivew and specified type "single" in Matlab, the output numbers were extremely large and wrong.
altenbach
2008-08-08 19:10:05 UTC
Permalink
Read the entire file as a plain string. No need to specify byte stream and such.
&nbsp;
Now simply typecast it to an array of DBL. Most likely, you need to convert to little endian, meaning you need to swap some bytes.
&nbsp;
smercurio_fc
2008-08-08 19:40:05 UTC
Permalink
I no longer have 6.1, but you can try to do the following:<img src="Loading Image..."> I did this in 7.1 with a file generated by Matlab and the file was read correctly, but I didn't do a whole lot of testing with it, so you have been forewarned.:smileywink:Message Edited by smercurio_fc on 08-08-2008 02:20 PM


read matlab dbl file.png:
http://forums.ni.com/attachments/ni/170/347960/1/read matlab dbl file.png
FElicia
2008-08-11 18:40:08 UTC
Permalink
This post might be inappropriate. Click to display it.
altenbach
2008-08-11 19:10:05 UTC
Permalink
This post might be inappropriate. Click to display it.
smercurio_fc
2008-08-11 18:40:10 UTC
Permalink
There is an array constant in the Array palette. Place it on the block diagram and then place whatever you need inside the container. For a DBL array place a numeric constant in there, and then right-click on the array element and set the representation to DBL.
Loading...