LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Load LVM File in Matlab

How do you load an LVM file in Matlab? I used the code:

load test.lvm;

But it returns this error message

"??? Error using ==> load
Number of columns on line 10 of ASCII file ......test.lvm
must be the same as previous lines.

Error in ==> PlotM at 1
load test.lvm"

Could it be the headers in the LVM file?
0 Kudos
Message 1 of 6
(18,958 Views)
LVM has an extensive header system which does not have the same number of columns as the data itself.  However, LVM was designed to be easy to parse, so it should be easy to get what you want.  If you just want your data, do a search in the file for ***End_of_Header*** and the column headers line will be next.  If you want to read the header data, check out the LVM spec.
0 Kudos
Message 2 of 6
(18,954 Views)
Do you know any example codes to do this? Im a novice at Matlab.

I found the code that takes the data and stores it in Matlab as a matrix.

Data = dlmread('smalltest.lvm', '\t', 18, 1)

Is there a way to extract this data?

Channels
Samples
Date
Time
X_Dimension
X0


0 Kudos
Message 3 of 6
(18,952 Views)
Unfortunately, I am the wrong person to ask that question, since I have never used Matlab beyond a simple demo.  However, I can give you some general tips that work in all the programming languages I have used.
  1. LVM files should be small enough to read the entire file at one time.  If it isn't you really need to use a different format.  Read the entire file in as a text string.
  2. Search the text string for the tag I mentioned above.  Then look for the second line afterwards (search for CR/LF or whatever your line terminator is).  This will give you the byte offset to start parsing the data lines
  3. Matlab should have a function to convert spreadsheet file text strings into arrays.  You can either use the data you have in memory (faster) or use a spreadsheet file read utility to read it off disk again, now that you know the offset to start reading.
Hopefully someone with some Matlab experience can chime in and help you more.
0 Kudos
Message 4 of 6
(18,943 Views)
If it's a one time thing, you can use File/Import to graphically select the data you want. 

If you're trying to automate, you can use the IMPORTDATA M command.  If needed, you can search the LVM files for the tag that was mentioned earlier so you can feed IMPORTDATA the line you wish to start at.

-Rob
-----
Rob Purser
Manager, Test and Measurement
MathWorks
rob.purser@mathworks.com
Message 5 of 6
(18,939 Views)
You can use this file from the MATLAB File Exchange:

"LVM file import", file ID: 19913

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=19913
0 Kudos
Message 6 of 6
(18,607 Views)