LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reading matlab mfiles into Matlab Scrip

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.

0 Kudos
Message 1 of 7
(2,296 Views)

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

 

Jamie S.

Applications Engineer
National Instruments
Message 2 of 7
(2,279 Views)

You can't "read in" m-files into the Matlab script node. The script node is a static object. You have to either:

  • Open the script file, select all the text, and paste it into the Matlab Script Node   -OR-
  • Place the m-file in the Matlab search path and then call a function from that script.
0 Kudos
Message 3 of 7
(2,258 Views)

m files are just txt file.  I just want to run the different mfiles and copy and pasting into the code will not work.

0 Kudos
Message 4 of 7
(2,242 Views)

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.

0 Kudos
Message 5 of 7
(2,236 Views)

Thanks for the advice.  I will look into how to do this. 

Here is my latest idea, but it doesn't work.

 

New Bitmap Image.jpg

0 Kudos
Message 6 of 7
(2,232 Views)

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.

0 Kudos
Message 7 of 7
(2,226 Views)