LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

MathScript: textscan equivalent?

To read LVM files acquired in LabView, I have been using lvm_import (http://www.mathworks.com/matlabcentral/fileexchange/19913-lvm-file-import) in MATLAB. However, I am attempting to now make use of MathScript so that all data can be acquired and analyzed in LabView, without third party software.

 

I am trying to modify lvm_import to account for all of the functions that MathScript does not support (structures, cell arrays, even try statements), but have run into an issue finding a replacement or workaround for textscan (http://www.mathworks.com/access/helpdesk/help/techdoc/ref/textscan.html).

 

Anyone with thoughts, or know of the equivalent function in MathScript? lvm_import uses fgetl to get each line in an LVM file, but I can't think of anything other than textscan to parse it the way I want. For the record, textscan is used in lvm_import by the original author.

 

Cheers. 

0 Kudos
Message 1 of 14
(3,912 Views)
Sorry, to further clarify...I know that textread exists, but I don't want to have to take the line, write it to a file, then read it back with textread. As far as I know, you cannot use textread on a string variable.
0 Kudos
Message 2 of 14
(3,909 Views)
Can you clarify why you aren't using the Read From Measurement File to get the data from the lvm file?
0 Kudos
Message 3 of 14
(3,889 Views)

Maybe I know the reason why jktang do not use the vi to read the text.

For example, the text has the data just like below

12    34

54 ,    34

   52  456

243,32

      35     5756

how to read it in LabVIEW very conveniently ? The format is so complex, because the separate will be a blank space or more.

For MATLAB,just use the function "importdata" and the data will be read quickly and accurately.

Does LabVIEW have the same function like "importdata"?

帖子被chenyin在 01-13-2010 09:55 PM
时编辑过了
0 Kudos
Message 4 of 14
(3,881 Views)

The lvm file was created with the Write to Measurement File and the Read From Measurement File can read it back.The file is just tab delimited text if I recall correctly and of course there are functions in LabVIEW for that. The main one being Read From Measurement File.Smiley Very Happy

 

Of course, I don't quite understand the use of Express VIs in the first place.

0 Kudos
Message 5 of 14
(3,877 Views)

Hi all, thanks for the responses. I suppose I wasn't too clear -- I need to analyze the raw data in the LVM file, not just display it. Read From Measurement File is an Express VI that I use to display the data, but in order to analyze it I need some actual algorithms.

 

Even if I port the output from the RFMF VI to a MathScript node, I still need to scan each line in the LVM file, delimit the contents, and analyze. I am looking more for the LabView functions to help me perform this task. While it seems simple to use any number of functions that read delimited text, further exploration into the MathScript version of them shows that NI has greatly reduced the parameterization of these functions, and there aren't any functions that parse strings with a delimiter like textscan does.

 

For example, textread  would do the trick, except the MathScript version of it doesn't let you add parameters (i.e. a delimiter). dlmread will read from a file, but not if it contains strings (just numbers). fscanf scans it as a single string...etc.

 

Thank you for the responses thus far!

0 Kudos
Message 6 of 14
(3,864 Views)
I'm even more confused. The output of the Read From Measurement File is a dynamic data type - not text. The dynamic data can be split into the different channels or converted to waveform data types which are cluster of to, dt, and y array. All of this informaton can be processed directly by a Mathscript node without having to read the file. There are hundreds/thousands of beginning users that analyze dynamic data with Express VIs.
0 Kudos
Message 7 of 14
(3,851 Views)
I'm not sure I can clarify any more, so perhaps I should work on joining the hundreds/thousands. Thanks for the reply.
Message Edited by jktang on 01-14-2010 11:43 PM
0 Kudos
Message 8 of 14
(3,830 Views)
I don't want to put words into Dennis's mouth, but what I think he is trying to say is that parsing the LVM file shouldn't be necessary.  You can use the Convert from Dynamic Data VI to get the numeric data from the Read From Measurement File VI in a variety of formats.  No parsing necessary.  You can then use that data, which is now double, waveform, or a variety of other types (you can choose how you want to view it) and put that into your MathScript node directly.  If I need to clarify that statement please let me know.  I hope this helps. 
Nick Keel
Product Manager - NI VeriStand and Model Interface Toolkit
National Instruments
0 Kudos
Message 9 of 14
(3,812 Views)

Nick,

 

You can put whatever words you want in my mouth. They were much more polite than the words I wanted to use.

0 Kudos
Message 10 of 14
(3,800 Views)