LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW 8.5 Problems using strings with MATLAB Script Node

Solved!
Go to solution

I'm having some issues that appear to be a bug that I can't figure out how to solve in using strings in the MATLAB script node.

 

I have two subVIs that do some computations and both contain a variable called "errortext" that is a string. Both subVIs do their computations using the MATLAB script node, so all outputs are defined in the script node.

 

The first subVI outputs a number and this string. The string is sent to an indicator on the front panel. The number is sent to the second subVI which does some more calculations and then outputs another string with the same title to an indicator on the front panel. This second string is different from the first (two different error messages should appear).

 

I've not had any problems with this in the past until this morning. This morning, it appears that both of these strings are now somehow mystically linked to each other. The second string only repeats what the first string says despite the fact that the first string is not being linked to the subVI where the second string lives. The only linkage between the two is a calculated double value that is passed from subVI #1 to subVI #2.

 

I attempted numerous things: I tried to rename the strings so that they don't have the same name. It originally wouldn't let me at all and gave me some error saying that the renamed string was an undefined variable (which is ridiculous). After deleting and replacing things, I finally got it to let me change the name, but now it doesn't display anything at all and further more I think it may be displaying yet another completely different string in my code!

 

I also tried to delete the string indicator and replace it. Again, it wouldn't let me at first. I would highlight it, press delete, and nothing. Eventually after replacing all of the subVIs with themselves I was able to delete the indicators, but this didn't help the problem.

 

Any insight to these pecular problems is greatly appreciated!

0 Kudos
Message 1 of 8
(3,890 Views)

Follow-up: Indeed it was using another string variable by the same name defined somewhere else in the code. I changed it to a new name and I got the error: "Error 1048 occured at LabVIEW: LabVIEW failed to get variable from the script server. Server:"??? Undefined function or variable 'errortext3'.

 

(errortext3 is the new variable name I defined)

0 Kudos
Message 2 of 8
(3,889 Views)

Also, I'd like to say that I did check out: http://digital.ni.com/public.nsf/allkb/3770DDA4593BF5D6862567D0007A31E6

 

My problem is none of those listed on that website. I also tried restarting MATLAB and LabVIEW. This still did not fix my problem.

0 Kudos
Message 3 of 8
(3,887 Views)

Well, it appears that whatever I did earlier fixed the bugs I was seeing. The error I received after the fact was indeed an error in the programming that I managed to find and flesh out.

 

I'm still not quite sure why it wouldn't let me rename the variable or delete the indicator though. I'd still be interested in hearing an explanation, but bottom line is that the problem has been solved by one or more of the things I did mentioned above to try and fix the problem.

0 Kudos
Message 4 of 8
(3,882 Views)
Solution
Accepted by topic author twolfe13

I don't completely understand what you did, as you were talking about variables in your fist post, and it wasn't clear whether you were referring to a variable you defined in the Matlab code, or you're trying to call an indicator/control a variable, which we often see on this forum (and which is wrong). That said, The Matlab Script node communicates with Matlab via ActiveX, and when you use it a small command window opens. This is the Matlab environment space. A variable that you define in one Matlab Script node will be visible in the other, even if it's in another VI (see attached figure for an example). That's because the script nodes are operating within the same environment space. It sounds to me as if that's what's happening.

0 Kudos
Message 5 of 8
(3,879 Views)

The variables in question were defined in MATLAB. In the case of the error string, they were then sent to an indicator on the front panel.

 

I also suspect that part of the problem was what you described. However, I don't see why it wouldn't let me delete the string indicator as discussed. I believe to get rid of it I replaced the subVI with itself. Once I did this I was able to delete the indicator.

0 Kudos
Message 6 of 8
(3,872 Views)

I've never seen the behavior you described with not being able to delete the indicator. Not sure if you'd be able to reproduce it so that others could check out what might be happening, and to see if the same thing happens with the current version of LabVIEW.

0 Kudos
Message 7 of 8
(3,866 Views)

I doubt it, it seemed pretty random and I didn't save a bad copy of my program. If I run across it again, I'll be sure to save it and share it though.

0 Kudos
Message 8 of 8
(3,864 Views)