LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Matlab Error 1048

I've investigated a bit more into an issue with the MatLab script node within LabView (7.1.1f).  I know that the code inside the script node (which called an external m file and lots of other stuff) is working from within LabView, because within the MatLab command window that appears, I can run the code and verify the output correctly.

However, the error off the MatLab script node block is the standard 1048 error for the "failed to get output variable", but I've checked to make sure that the shipped Matlab examples work, so that I have those necessary updated libraries as suggested by the appropriate tech note.

The error message from Matlab itself always seems to be the version string from Matlab, which is the weird part.  I've tried Matlab 7.0.1 and 7.0 (after seeing a post that suggests there's an incompatibility with 7.0.1 and LV 7.1.1f2). 

The only other aspect I can think of is that Im using strings as input and output from the Matlab script which may get long but are effectively finite.  However, to see if it was the size, I played with the Lorenz attractor problem and increased the size of the output numerical array but there was no problem from this end.  This also increased the time of the matlab operation to comparible with my Matlab functions, but it still worked.

I think the error message being the version string is the strong indicator of what is going on here but I can't figure it out.  Any helpful suggestions?

0 Kudos
Message 1 of 3
(3,159 Views)
I hate to answer my own question but I figured it out after a few tests.

String data type outputs (and possibly inputs but I've yet to hit that issue) from the MatLab block seem to be limited to 256 characters.    If you create a Matlab script with "out=blanks(257)", and other connections as necessary with the String output 'out', you'll find weird returns from Matlab as I described above; set that number to 255 or less, and the script runs happily.

If you need larger strings, you need to first make them into a double byte array within Matlab (via double()) and then convert them back to a Labview string via the "Byte Array to String" block.


0 Kudos
Message 2 of 3
(3,153 Views)
Hey M_N,

Thanks for posting the updated information.  Don't hate to answer your own questions! 

Thanks!
Andy F.
-----------------------------------------------------------------
National Instruments
0 Kudos
Message 3 of 3
(3,139 Views)