11-28-2013 09:15 AM
Dear all,
I use Labview 2011. I want to load Mat files created with Matlab. I tried to use the Storage/dataPlugin with the Matlab dataPlugin (downloaded from : http://www.ni.com/example/29178/en/). Using the 'Data file viewer', I can see the data contained in the Mat file (vector A and C, matric B) but I don't know how to extract them automatically using the 'Read Data' function. here is the VI.
any ideas?
Regards,
Cedric
12-02-2013 05:39 PM
Hey Cedric,
When it comes to reading your .mat file created from The MathWorks, Inc. MATLAB® software you do indeed want to use the DataPlugin and the Data Storage functions. For implementing the function calls, it's easiest to think of the file like a database that we can extract values from via queries. So, you open a connection to the file (Open Data Storage), read data from the file (Read Data function), and close the file (Close Data Storage). And, with the Read Data function you can either query the data directly or get an array of references to the channel groups. For extracting specific data, or if it makes more sense to you as you code it, it's typically easiest to query the data directly. So, instead of reading the channel groups you would configure the Read Data function to as follows:
Object type to read: Channel
Property to Compare: Name
Output Data Channels As: This depends on what you're storing (most likely you'll want "Array of Doubles")
Keep in mind that the Data File Viewer is an unlocked (no password) subVI that uses the low level data storage functions to access the data in your .mat file. So, if the Data File Viewer is seeing the data you want then you can also re-use some of that code to output the data if you don't want to write your code from scratch. However, make sure you save a new copy of the VI before making any changes. Also keep in mind that that function is doing a lot of extra stuff for organization so if you're simply extracting data from the file starting from scratch may be easiest.
Hope that helps!
MATLAB® is a Registered Trademark of The MathWorks, Inc.
--Ryan S.
07-20-2016 02:52 PM
I found this explanation very confusing, until I stumbled onto the solution. My .mat file was produced by a Picoscope brand oscilloscope, which can also export .csv files. In the .csv files, the channels were called "Channel A" and "Channel B", but not in the .mat file. The .mat file contains channels called, for example, Scalar and Vector; under Vector there were channels called A and B. I found all these facts using the Data File Viewer. You don't want to try to read the channel "Vector" (or "Matrix" or whatever), rather, go directly to the channel underneath that; here, channel "A".
I'm attaching my example, back-saved to Labview 2009, along with the .mat file I was reading.