02-09-2012 06:17 AM
I am running a MatLab script node with MatLab 2010a open on my computer, running with LabVIEW 8.5.
I have the script node with the correct inputs to it, and then some basic maths in the code, however when it comes to output, all the values are zero.
When I had an input that it passes straight over to the output (of the same name) it works without a problem, but if I want to change the name of the output it outputs zero, along with if I attempt to do any maths using that input.
I've attached the VI, if anyone gets a chance to take a look through and could tell me why MatLab can't seem to do maths anymore that'd be really helpful!
I have tried changing the format of the input and output (I think in the attached VI they are both set to DBL) and my apologies for the masses of outputs I've included - I wanted to see if any of the outputs were changing at all!
Thanks in advance,
Dani
02-09-2012 06:25 AM
P.S. the toggle button on the front panel needs to be set to False for the bit of code that I'm trying to sort at the moment. When it runs with True it just displays Not A Number - I haven't got round to fixing the True bit yet!
Additionally, I just realised I'd saved it mid-change so the input has been changed to a DBL whilst the output is now changing to EXT. I don't know why I saved it at that point! But I know that will be the first thing you may recommend I alter
Dani
02-09-2012 07:53 AM
Learn to use error clusters. If you create an error output on the script node you will see that you are getting a Matlab error: "Error: Unexpected MATLAB operator". Clearly, your script is incorrect. Like your other post, you seem to have problem with Matlab syntax, not LabVIEW.
Of course, that doesn't mean you don't have LabVIEW issues. You do:
02-09-2012 10:02 AM
Thanks for that.
It is a subVI from a much larger program - It will only run once when run in the entire process.
The subVI was written by the previous person on this project - I am trying to update it, so thank you for the comments re. the clusters and arrays - I will ensure to edit that to index array for simplicity.
Thank you for your comments on the codes too - I had read different articles etc, that had differences on whether the 'if' command was capitalised or not, so thanks for clearing that up for me!
I will ensure to add error clusters from now on; that seems to be an invaluable tool!
Thanks,
Dani
02-10-2012 04:14 AM
I am still getting an Error in my MatLab script, but it runs without a problem in MatLab itself. I receive the 'Unexpected MatLab operator' as you said before, but I'm not sure what this is as it doesn't pinpoint the line. With full realisation that this is a LabVIEW forum, but do you have an idea what the unexpected operator could be? Is there something I'm missing to start off my code?
Thanks,
Dani
02-10-2012 10:07 AM
Hello Dani,
I often support users with textual math, or imported textual code in LabVIEW. When there are potential bugs in the imported text, the same rules as text based debugging apply.
One technique is to divide the lines by half.
What is the significance of the (**) operator?
Should '-dG' be replaced with (-1 *dG)?
That might be a starting point.
For the minute, I could also suggest that you may want to use a Formula Node box. It supports textual math in LabVIEW using standard 'C' operators, and does not require MatLab to be installed on the PC.
By all means, however, I understand the importance of re-using something that has already been tried and tested in MatLab.
Regards,