LabVIEW MathScript RT Module

cancel
Showing results for 
Search instead for 
Did you mean: 

using matlab *.m functions in labview

Hi,

 

 

I'm feeling that this is a basic question, sorry about that.

I have some functions created in MATLAB (*.m files), there is a loots of code in this .m files.

My question: How can I include or access this functions in LabView? using MathScript? How?

 

 

 

 

 Best Regards

Hugo Guerreiro

0 Kudos
Message 1 of 20
(32,792 Views)

Hello Hugo,

 

You can call functions that you have defined in .m files using MathScript.  There are some good instructions about how to do this in the help topics called "Defining a Function or Script" and "Calling User-Defined Functions from LabVIEW MathScript".

 

To briefly summarize these topics, first you need to add the directory that contains your functions to the MathScript Search Path. You can view or modify the search path for the MathScript node in the Tools>>Options dialog box or for the MathScript Window in the MathScript Properties dialog box. Then you can call your functions using the name of the .m file that contains the function.

 

Good luck!

jattas

Message 2 of 20
(32,786 Views)

Hello Jattas, you was most helpful.

 

I'm already able to call the function files that I want.

 

I'm trying to load the *.mat files but with no success, how can I make it?

 

Thanks

Hugo Guerreiro

Message 3 of 20
(32,739 Views)

Hello again Hugo,

 

Glad to hear you're having some success!

 

You can use the MathScript 'load' function to read many *.mat files saved with The MathWorks Inc. MATLAB® software. The help for this function is available here. There are a couple restrictions on its use with .mat files: they must have been saved using version 6.0 or eariler of the MATLAB software and they must only contain data types that are supported by MathScript (Only 2D Arrays. No structures, higher dimensional arrays, or cell arrays).

 

If the load function is not working for you, please let me know what behavior you are seeing. Are you receiving an error? Or incorrect data? It may also help if you post your .mat file for us to analyze.

 

Good luck,

jattas

 

 

MATLAB® is a registered trademark of The MathWorks, Inc.

Message 4 of 20
(32,721 Views)

OK, I fixed that problem.

But, a thousand occur...

 

It seams that MathScript can't save in to *.mat files..... is this true?

 

Another question.... Can I call other user defined functions (*.m) in the user defined functions called in MathScript?

 

I'm begging to be disapointed with the implementation of matlab code in LabView (sorry)

 

Thanks

Hugo Guerreiro

0 Kudos
Message 5 of 20
(32,697 Views)

Hi Hugo,

 

Yes, MathScript can not save data into MAT file format.

 

You can call nesting user defined functions in your script as long as all those user defined functions locate in MathScript Search Path.

 

Feel free to let us know your questions.

Message 6 of 20
(32,691 Views)

I develop program in mathlab for signal analysis.

But i want to do this analysis in Lab view,

Which option is better ?

1. Call same math lab program in lab view.

2. Or develop new program for analysis in lab view.

 For analysis currently i am using 60 txt files. Is it possible to call these 60 txt files in lab view also. 

In future I wants to do this analysis in real-time.

Is it possible to measure and process signal in real-time?

 With Best Regards,

Rajesh

 

 

0 Kudos
Message 7 of 20
(32,679 Views)

Hi Hugo,

 

As ttrr mentions, you cannot save data to .mat files in MathScript. However, you can save to several other formats that are readable in MathScript, LabVIEW, and other applications. Some options include .mlv, .tdm, .tdms, .csv, .txt, and .xls.

 

Thanks,

jattas

Message 8 of 20
(32,660 Views)

Hi Rajesh,

 

Both of your options have their advantages. To go with option 1 you can use the MathScript Node. It supports certain of the syntaxes used in other math packages. As discussed above, you can also call your textual .m files in MathScript. And with the introduction of the MathScript RT Module in 2009, it is possible to measure and process signals in real-time using MathScript.

 

Option 2 can also get you where you would like. It might require a lot of manual translation of your code, which can be tedious and error prone. But you would have the advantage of all of LabVIEW's data types, performance tuning tools, and analysis functions. And all of this can run in real-time too.

 

Often we have found that a hybrid approach works best. Some parts of your algorithm may be best expressed textually and other parts may be best expressed graphically. Choosing which one requires striking a balance between many factors including code readability, performance, language features, debugging tools, and development time.

 

Please let us know if you have other questions about this.

 

Thanks,

jattas

Message 9 of 20
(32,657 Views)

Hi Jattas,

 

 

 

If I save and load data into and from several *.xls files, is this as a good performance?

Please note that I using this in real time.

 

 

 

Thanks

Hugo Guerreiro

0 Kudos
Message 10 of 20
(32,648 Views)