LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reading matlab .m file

Hello,

I have a signal in matlab .m format and I want to read it by using LabVIEW for further processing.

In matlab_file_reader you can see my approach. As documentation I have used the document Mat-File format (you can download it from http://www.mathworks.com/access/helpdesk/help/pdf_doc/matlab/matfile_format.pdf)

The signal is also attached bellow, I change the extention from.m to .txt to be able to attach the file

As you can see in the Endian Indicator of the Header Flag Field has a value of "IM" which indicates that the signal should be read by inverting the bytes order. I perform that and I start to read the values. On the vi attached only the two first values are readed.

The values that I obtain are:
value 1 = 6
value 2 = 1

and they should be (when the signal is readed with matlab - load(signal) command):
value 1 = 0.6736
value 2 = -0.0911

as you can see there is something wrong. The data type that I read from the Sub Element Tags are 32-Bit Unsigned and 32-Bit signed for the first two values respectively, something that can not be if you see the expected values.

Does anyone know where the problem could be?
Download All
0 Kudos
Message 1 of 15
(4,772 Views)

Hi,

Is there any reason why you cannot use a Matlab Script node and that command to read the data into LabVIEW?

Craig

LabVIEW 2012
0 Kudos
Message 2 of 15
(4,764 Views)
Also i found this thread which had a couple of example solutions.  Perhaps they may be able to shed some light on the situation.
Craig
LabVIEW 2012
0 Kudos
Message 3 of 15
(4,755 Views)
It looks like your trouble is stemming from the way you are parsing values from the array.  Pages 1-19 and 1-20 of the aforementioned pdf document show that the array data contains headers with array flags, dimensions, and the array name before it actually presents any data.  You just need to parse out those values before attempting to access the data. 

Also, I should mention that your bit manipulation could also be accomplished via a typecast and be a much simpler implementation.  See the image below:



Cheers


Message Edited by Spex on 11-13-2007 08:48 AM
Spex
National Instruments

To the pessimist, the glass is half empty; to the optimist, the glass is half full; to the engineer, the glass is twice as big as it needs to be has a 2x safety factor...
0 Kudos
Message 4 of 15
(4,741 Views)
Hi,
 
I have been looking at this for a while now and yes you have missed out the array subset flags, array size, and array name registers.  Once you process all of those you get into the Array itself which in your case is a miDOUBLE IEE 754 format. 
LabVIEW 2012
0 Kudos
Message 5 of 15
(4,722 Views)
Hi,
 
I have been looking at this for a while now and yes you have missed out the array subset flags, array size, and array name registers.  Once you process all of those you get into the Array itself which in your case is a miDOUBLE IEE 754 format.  Your
LabVIEW 2012
0 Kudos
Message 6 of 15
(4,721 Views)
Hi,
 
I have been looking at this for a while now and yes you have missed out the array subset flags, array size, and array name registers.  Once you process all of those you get into the Array itself which in your case is a miDOUBLE IEE 754 format.  Your array
LabVIEW 2012
0 Kudos
Message 7 of 15
(4,720 Views)
Hi,
 
I have been looking at this for a while now and yes you have missed out the array subset flags, array size, and array name registers.  Once you process all of those you get into the Array itself which in your case is a miDOUBLE IEE 754 format.  Your array size
LabVIEW 2012
0 Kudos
Message 8 of 15
(4,719 Views)
Hi,
 
I have been looking at this for a while now and yes you have missed out the array subset flags, array size, and array name registers.  Once you process all of those you get into the Array itself which in your case is a miDOUBLE IEE 754 format.  Your array size is 1x100000 etc.
 
Craig
 
Sorry about the duplicate posts, i dont know what happened,  must of been leaning on a key or something.... sorry!
 


Message Edited by craigc on 11-13-2007 11:05 AM
LabVIEW 2012
0 Kudos
Message 9 of 15
(4,719 Views)
OK, now I am able to read until the array size (1*100000). According to figure of page 1-20, then comes the array name, so I should read 4 bytes indicating a 1 (for miINT8) and the bytes size of the actual name of the array. After that I should read  this number of bytes to get the name; and then 4 bytes to get the data type of the array elements and its size. Just after that I should be able to start to read the array data.

as you can see in the attached vi, when reading the 4 bytes after the array size i obtain 65537 which has no interpretation. But the 4 bytes after that indicate that the size of the array name is 120.

so If after the array size I jump 4+4+120 bytes (data type for array name + size of the array name + 120 bytes) I should be able to read the data type of the array elements. However, by doing this I obtain a 1002756845 which again has no interpratation.

craigc, how did you read that the data type of the array elements was miDOUBLE IEE 754 (i.e. a 9 value)?

greetings,
Crimiolvic
0 Kudos
Message 10 of 15
(4,686 Views)