LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labview string to which matlab data type

Hi
 
I'm using my labview programme to write a file which will be read off using matlab. I face problem of enabling the matlab to read the 'string' datatype written by labview. Those in 'double' datatype is fine. There's no string data type in matlab except 'char' which is not showing wat i've written.


Message Edited by 1000 on 01-11-2008 10:05 AM

Message Edited by 1000 on 01-11-2008 10:07 AM
0 Kudos
Message 1 of 6
(4,327 Views)
So you're writing an ASCII text file with LabVIEW and then reading the text file into Matlab?  If you're using Windows, you might want to consider using a Matlab script node instead, depending on your application.

Do the strings look correct when you look at the text file with Notepad?

I'm not sure if Matlab can read string data from text files.  What happens if you use " class(somevar,'char') " on the data after you load it?
0 Kudos
Message 2 of 6
(4,316 Views)
If you use a MATLAB Script node, then do this to get the MATLAB string to a LabVIEW string:






Message Edited by Derek Price on 01-11-2008 01:35 PM
0 Kudos
Message 3 of 6
(4,312 Views)
Matlab can read data from text files just fine. It's true that in Matlab strings are stored as character arrays, but that would have no bearing on being able to read them. The first response assumed the OP is generating an ASCII file. That's not immediately apparent. So, the question becomes, how are you generating the file, and can you post an example?

Also, there's no need to use the Matlab node to read the file in Matlab unless you are trying to do this as part of your program. In that case, the logical question would be what is it that you're doing in Matlab, and can you do it in LabVIEW instead?
0 Kudos
Message 4 of 6
(4,305 Views)
The labview programme is used to capture data of signals from a spectrum analyzer. The data are written to a .dat file using binary format. What I have to add on is to include a string data to the .dat file as the first binary. The file will be process using matlab and it will produce a graph for the spectrum, as well as the string which will be read off using the fread function of matlab through the workspace window.  Thanks!
0 Kudos
Message 5 of 6
(4,286 Views)
You still haven't indicated exactly how you're writing the file out. LabVIEW code, please. My guess is that you're probably using the Write to Binary File function directly. That function has an input named "prepend array or string size". I suspect you have it unwired, which means that when you write out the string the length of the string is being prepended to what's being written out to file.

Also, is there any reason you can't display the data using the graphs that come with LabVIEW?
0 Kudos
Message 6 of 6
(4,260 Views)