LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

remote matlab script

Hi,
 
Here is the problem i have at the moment.  I have LabVIEW 8.2 running on a pc in one location and need to run some matlab script files in my program.  After much deliberation trying to get the matlab script to run under a mathscript node i have come to the conclusion along with my NI rep that a particular function does not work under mathscript (cubic Interpolation).  So i need to run this .m file on another machine which has MatLab running on it, get some results and then copy said results back to the machine with LabVIEW on.  This is become a mojor hinderence on an "automated" test system by running back and forth between machines.  I was thinking there may be a possible way of using a network connection to the machine with Matlab on it to run the script and copy back the results files.  My Initial idea was to run a remote vi which uses the system exec vi and runs a batch file to run said script and copy back over the network.
 
Problem is i have no experience of remote connections etc and was hoping someone might point me in the right direction.  Do i go for TCP IP, ActiveX or remote panels? etc etc
 
Thanks in advance
Craig
LabVIEW 2012
0 Kudos
Message 1 of 13
(3,777 Views)
I would choose TCP-IP, but don't know how har it is the create a matlab app that listens on a port for a connection to receive commands over TCP-IP.

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=11802&objectType=FILE

The link shows a tcp-ip example in matlab.

Regards,
André (CLA, CLED)
Message 2 of 13
(3,757 Views)

Thanks for the link Andre,

Although i dont think it is quite what i am after as i do not have the connectivity toolbox for matlab.  I have a script that just reads a file, performs some math and then returns a file (.csv's).  I am still thinking of just running a batch file on the remote matlab machine which runs the script from the command line using "matlab -r myscript.m".  However the bit i am unsure of is how to connect to that machine in arder to run that batch file.  Am still thinking that it should be possible using the system exec.vi on the remote matlab machine but how to do that i am unsure of.

Thanks again for the reply though Andre

Craig

LabVIEW 2012
0 Kudos
Message 3 of 13
(3,733 Views)
I'd use a datasocket connection.  On the remote machine build a vi using System Exec which will call the Matlab script with the -r function.  Then place that in a case structure and send a bolean control across the network via datasocket.  Then have the remote vi pass the standard output from the Matlab script back across the network via datasocket. 

Hope this helps

later
chris

Message 4 of 13
(3,725 Views)
Hello,

Could you provide the name of the function that you were searching for?  Additionally, if you could provide a sample usage of the function and expected output, it would help us more quickly investigate and implement a function.  You can view the available interpolation functions in the LabVIEW MathScript approximation function class by typing
help approximation
I also know of another function offhand that generates an interpolating polynomial: pchip.

Grant M.
Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments
0 Kudos
Message 5 of 13
(3,710 Views)

Hi Cmpowell,

That is the kind of idea i was looking for and datasocket did not occur to me so thanks for pointing me in that direction.  I will go off and have a read and try a few vi's over the course of the day and let you know how i get on.

Thanks for the Input 😄

Hi Grant

The function that is falling over is "Interp2" (from my dodgy memory)  which is a 2D Interpolation.  I use meshgrid also.  In effect the process is data in -> meshgrid it -> Interp2(x,y,z,xi,yi,cubic) -> reduce data set -> data out (or something along those lines).  However using the cubic interpolation method in the Interp2 function gives NaN and missing data points on my data set.  I have gone through this whole process with NI support including the actual code and a results file, however i am not at liberty to post examples here before you ask.  If you wish i can dig out the ref numbers and/or e-mails for you.

Also in a further script it was observed that the filtfilt function does not give the same results as the matlab's filtfilt function.  This function is supposed to remove dc or end effects of the filter but does not seem to do so under mathscript.  I have not contacted NI support over this issue as a matlab guru whom i worked with created his own filtfilt function (filtfiltphil hehe) using matlab primitives which gave identical results under mathscript to those under matlab (for my purpose at least).

Ideally Grant i want these functions working under LabVIEW but i can understand this will take time and money.  If i can assist in anyway to get these functions working correctly please let me know although it will have to be through a channel other than the forum for confidentiality.

Thanks in advance

Craig.

Message Edited by craigc on 11-02-2007 05:21 AM

Message Edited by craigc on 11-02-2007 05:21 AM

LabVIEW 2012
0 Kudos
Message 6 of 13
(3,703 Views)


@craigc wrote:

I have gone through this whole process with NI support including the actual code and a results file, however i am not at liberty to post examples here before you ask.  If you wish i can dig out the ref numbers and/or e-mails for you.


Craig,
 
I'd like to follow up with our support engineers on this issue.  Can you provide me with the service request number(s)?
 
Thanks,
Travis H.
LabVIEW R&D
National Instruments
0 Kudos
Message 7 of 13
(3,682 Views)
Hi Travis
They handled my Case very well and was pleased with the service although we could find no solution within mathscript to continue with.  My service number was 580776 And i live in the UK so went to UK support.
Thanks
Craig
LabVIEW 2012
0 Kudos
Message 8 of 13
(3,646 Views)

Thanks cmpowell,

Managed to get it working through Datasocket.  This has enabled me to do more across the network and speed up my test times too!

Travis

Did you get my support numbers OK and is there any updates out of curiosity

Thanks in advance

Craig

LabVIEW 2012
0 Kudos
Message 9 of 13
(3,565 Views)
No problem man, I use datasocket alot, especially  in a producer/consumer context, it's a fantastic tool.

Good luck with your project.

later
cp

0 Kudos
Message 10 of 13
(3,555 Views)