09-21-2011 08:48 PM
I am not an matlab guy, I am just trying to read in m-file that I have created. Not sure how to do this.
I thought this should be simple looking ath teh Lorez Diff Eq example.
09-22-2011 08:07 AM - edited 09-22-2011 08:10 AM
Hi Sendtohen,
I'm Jamie, a Applications Engineer at National Instruments (UK).
There are a number of methods of importing m-files into the LabVIEW environment including the Matlab(R) Script Node used in the Lorez Diff example, this uses ActiveX and requires a valid license of Matlab(R) on the machine you are running LabVIEW, but also needs Matlab(R) to be open when it is executing.
If you are importing a m-files on an infrequent basis may I also suggest you trythe procedure in the KnowledgeBase link below:
http://digital.ni.com/public.nsf/websearch/2f8ed0f588e06be1862565a90066e9ba
This involves converting the m-file to a tab delimited ASCII file and then importing the data using the Read from Spreadsheet VI in LabVIEW.
Hope this helps
Regards
Jamie
09-22-2011 08:18 AM
You can't "read in" m-files into the Matlab script node. The script node is a static object. You have to either:
09-22-2011 12:18 PM
m files are just txt file. I just want to run the different mfiles and copy and pasting into the code will not work.
09-22-2011 12:59 PM
If you have different m-files for different situations then why can't you simply have a script node for each one? If you don't want to do that, then you can simply "functionalize" your scripts. Just add the function statement at the top of the script. Then you can use the call statement inside the Matlab Script Node to call whichever script you need.
09-22-2011 01:40 PM
Thanks for the advice. I will look into how to do this.
Here is my latest idea, but it doesn't work.
09-22-2011 04:27 PM
Well, that doesn't work because it doesn't actually do anything. All it does is create a variable called "mFiles", whose value happens to be the contents of the file. That still won't execute it since you cannot "execute" variables.