From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW errors writing string signal channels to MATLAB (.mat) file using MATLAB DataPlugin

Solved!
Go to solution

Hello All,

I’ve encountered an issue with the MATLAB Data Plugin. I hoping that someone can describe a work-around or confirm that I am out of luck.  The issue that I am having involves writing string data channels to a MATLAB (.mat) file from LabVIEW. I have to output some data from an existing LabVIEW application in MATLAB format for transfer to an external customer.  It appears as if any attempt to write a string channel containing a non-empty string value results in a failure to output any channel properties (Name,Description,  signal, etc.).  If an empty string value is written then the channel properties are present in the output.

 

I’ve created a simple VI to demonstrate the issue (attached). Toggle the “Use Empty String for Inputs” boolean control ON to see the desired (correct) results in the “ChanNameArray” indicator.  Alternatively, you may clear or modify ant input prior to executing the VI.

 

The correct structure of the output file should contain three channel groups (“Vector”, “Labels” and “Numbers”). The “Vector”  group should contain one channel named “FileId”.  The “Labels” group should contain 9 channels named “Str_0” …”Str_8”.  The “Numbers” group should contain 6 channels named “Num_0” through “Num_5”.

Correct_Output.JPG

Fig. 1 Correct (desired) output obtained with empty string channel data

The channel name for non-empty string channels will be missing the channel name within the ”ChanNameArray” indicator as seen below.

 

Incorrect_Output.JPG

Fig. 2 Incorrect output obtained with non-empty string channel data on some string channels

Any guidance is greatly appreciated.

--

Regards,
     Brian

0 Kudos
Message 1 of 3
(2,179 Views)

Hi Brian,

 

This is (unfortunately) expected behavior. LabVIEW's DataPlugins do not support writing strings with binary data.

 

Luckily, there is an easy fix. If you run your strings through the String to Byte Array function, this will convert them to an unsigned byte array that can be written in the same way that you are writing the strings currently, albeit successfully.

 

This is documented in slightly more detail in the Write Data Express VI documentation in the LabVIEW help.

 

Best,

 

Duncan Waldrop

Technical Support Engineer

National Instruments

0 Kudos
Message 2 of 3
(2,140 Views)
Solution
Accepted by topic author BA100

Duncan,

 

Thanks for the suggestion.  After further investigation I discovered that there is no error in writing string channels.  There was an error in my configuring the Get Properties Express VI to read the channel names.  Apparently, when querying a string channel this VI must be configured to output an array of strings even if the output signal is not being connected.  This was my error because I was only verifying the channel Name and not the actual signal contents.  I've attached a revised version of my original VI that works for my purposes.

This must be set to Array of Strings for string channelThis must be set to Array of Strings for string channel

 

0 Kudos
Message 3 of 3
(2,135 Views)