02-02-2012 04:58 AM
Can you call a subVI in MatLab script node, or does the SubVI 'node' always have to be used?
If this can be done, how is it done - can 'load' be used followed by the subVI address on the computer?
Any help would be much appreciated!
Thank you in advance,
Dani 🙂
02-02-2012 08:09 AM
No, you cannot call a subVI from a Matlab script node. Calling the Matlab script node accesses the Matlab ActiveX server, at which point Matlab essentially takes over.
What exactly are you trying to do?
02-02-2012 05:47 PM
Hi, thanks for your reply!
Essentially, I'm rewriting a current program and replacing the current operations done in LabVIEW with MatLab script. So for example in the attached file the VI runs a true/false node, and for true it runs one SubVI, and for false it runs an alternative. The true/false is an easy thing to rewrite in MatLab, however I wasn't sure if or how to call the different subVIs. I think the only way around this may be to write the SubVIs as .m files and call them through the MatLab node?
Thanks,
Dani
02-02-2012 11:14 PM
Why are you rewriting in Matlab when you already have it in LabVIEW?
02-06-2012 04:08 AM
As that is the task I have been set! To convert the mechanics of the labview programme into MatLab script (as this is what our students are taught) but using the LabVIEW front panels for their design and user interface.
Okay, so the subVI's can't be solved, in which case I have programmed them up and will call them as .m files I think. I am experiencing problems in the MatLab script node now, for some reason my script doesn't recognise the input variables coming from LabVIEW... any ideas how I would make it understand that this is user input?
Thanks again for your help!
Dani
02-06-2012 04:14 AM
Oh and just to explain the attached picture - basically the user inputs their gas selection from gases 1 to 5 (entered on the front panel) and then inputs the desired coefficient (from numbers 1 - 6).
This should then use the correct input of data and read the coefficient from the correct matrix at the correct row.
Any guidance would be much appreciated!!
Thanks,
Dani
02-06-2012 08:06 AM
Do not use the Array to Matrix conversion function. It is pointless in this case since your array is 1D to begin with. Set the datatype of CO2, etc to 1D Array of Real. If you must have them as 2D arrays, then use the Build Array function rather than the Array to Matrix. The matrix datatype is a specific LabVIEW datatype, not a generic datatype.
You are redefining Gasselection with the "global" line. You've already defined it by having it as an input to the script node.
Also, Matlab array indexing starts at 1, not zero. Thus, the line "Coefficient = CO2(0, coefficientselection)" would be invalid.
Why are "Gas" and "Coefficient" floating points? They're indexes into arrays, thus should be I32.
02-06-2012 08:36 AM
Thank you so much for that - I have added in your corrections but it still doesn't display the value in the output
I have attached what it looks like now - realised the selection was also the wrong way round for CO2 etc.! Do I need to be using the MathScript editor window with this even though it is in a MatLab script node?
Thanks so much, I've spent many hours getting more and more frustrated with this, so any ideas and corrections you have are very very much appreciated!
Dani
02-06-2012 09:38 AM
"Coefficient = CO2(1, coefficientselection)" is actually performing redundant indexing within Matlab since CO2 is a 1D array. What is the value of the Coefficient control?
You can't use the MathScript editor window. MathScript and Matlab are two different things.
Please attach your code if you still have further problems.
02-06-2012 09:57 AM
Thanks, I don't really understand what 'redundant indexing' is, as I'm unsure how to change the code! I've attached the coefficient table and a picture of the script if you could take a look that'd be great! I've commented out most of the code to see if I can just get one value out first of all. I'm unsure where to go from here - I can't figure out how to attach the VI by itself, sorry!
Thanks so much,
Dani