LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

strange MATLAB script behavior

I am running a simple MATLAB script in LabVIEW. Basically, it just read data from a *.mat file and send data out for LabVIEW to plot it.

 

For some reasons, I have to add something irrelevant at the end, in this case " strMssg = 'strange' ", for the script to work properly in the LabVIEW MATLAB script node. Without this " strMssg = 'strange' ", x and y are not updated, so even I call a different file, x and y stay the same, and the "Preview XY Graph 3" graph does not change. 

 

The MatLAB script node works if I make the above script into a function, and just call this funtion in the MatLAB script node.

 

Is this a bug, or can someone tell me why this MATLAB behavior?

 

Thanks.

 

Ian 

0 Kudos
Message 1 of 4
(2,651 Views)

Does it have to be that exact message?  Or will any line of code in there work?  And if the first situation, how did you figure out it had to be exactly that?

 

If you don't have it, does the matlab code get stuck in a loop?  Or does it actually finish and you just don't updated data?

0 Kudos
Message 2 of 4
(2,636 Views)

Anything after the last "end" will make the script code work.

 

I actually have found out that if I end the script with "end", it generates an error, but MATLAB script node still sends out whatever in the memory of "output".

 

The solution is to always end a line with a ";" which I should do in the first place.

 

New to MATLAB, still love LabVIEW better when I do not have to worry about any syntax.

 

Thanks.

 

Ian

0 Kudos
Message 3 of 4
(2,624 Views)

@TulaRen wrote:

 

The solution is to always end a line with a ";" which I should do in the first place.

 



That was going to be my next suggestion.  I haven't used MatLab, so I don't know the idiosynchrosies of its syntax.  I've used formula nodes to a limited extent and I know the end of command punctuation can be particular there.  (And in some text-based languages I used, I think Pascal was one, end of line punctuation is particular and not always that easy to figure out when you need and when you don;t.)  So I figured Matlab must have the same situation and maybe the combination of the loops and ends and the punctuation or lack thereof were confusing the compiler and maybe it was getting stuck in a loop.

0 Kudos
Message 4 of 4
(2,610 Views)