LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to define "byte stream type" for "open file"?

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
0 Kudos
Message 1 of 9
(4,982 Views)

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. 😄

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.

0 Kudos
Message 2 of 9
(4,976 Views)
Looks like 7.1:

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 here.

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
0 Kudos
Message 3 of 9
(4,970 Views)
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.
0 Kudos
Message 4 of 9
(4,949 Views)
Read the entire file as a plain string. No need to specify byte stream and such.
 
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.
 
0 Kudos
Message 5 of 9
(4,945 Views)
I no longer have 6.1, but you can try to do the following:

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.Smiley Wink


Message Edited by smercurio_fc on 08-08-2008 02:20 PM
0 Kudos
Message 6 of 9
(4,941 Views)
Thanks a lot again! I'll try the type cast. By the way, how to create the DBL array connected to the type cast? Is that a constant/indicator/control?
0 Kudos
Message 7 of 9
(4,899 Views)
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.
0 Kudos
Message 8 of 9
(4,895 Views)


FElicia wrote:
By the way, how to create the DBL array connected to the type cast? Is that a constant/indicator/control?

Let's assume you already have the terminal for the "data" indicator. SImply right-click in and select "create constant". You'll get a diagram constant of the same type to do whatever you want with it. 😉
0 Kudos
Message 9 of 9
(4,891 Views)