Using complied Matlab in Labview
I have a Labview vi that uses Matlab to do calculations and plotting by calling a matlab script in Labview. I also have complied that same Labview vi so it can run on other machines without labview, but the machine must have Matlab since the vi calls Matlab scripts. Is there any way I can use a complied version of Matlab and a complied version of Labview to run on a machine without both program licences?
Hey jbirdthe3rd,
Thank you for contacting National Instruments. From the information you have provided here, I don't believe you are going to be able to achieve this specific behavior. LabVIEW has a run time engine that allows for this type of operation, and it looks like you have used this with the LabVIEW portion of the application. The only suggestion I can provide in this case is to consider using LabVIEW Mathscript. More information about its functionality can be found from the following pages.
NI LabVIEW MathScript
LabVIEW MathScript Function List
I hope this helps! Let me know if there is anything else I can help with or clarify. Have a great day!
Jason W.
National Instruments
Applications Engineer
Similar Messages
-
Using a "fopen" call in a DLL made with MatLab for Labview
Dear Sirs:
My name is Juan Crespo and I write you from Spain. I answer if you could help me with a Labview problem. This is the problem.
I want to write a DLL for being used in labview, and i want to use matlab for write this DLL. I have been searching in the web and reading the NI "using external code in labview" manual in order to know what I must do.
I know that if I want to use MatLab, I must build a "wrapper function" to avoid the different data type between MatLab and C. I have found on the web -Thanks to Alberto Sanchez- one example about how could a DLL could be written.
But it exist one diference: I want to read a plain text file that has the input data. so I must read the file, store
the data in an array and then pass this array to the "interface functions" but in a simple example this dont works
My question is ¿How could I open a text file in order to use it as input data in a DLL in Matlab?
Attached to this message is the code I use as "wrapper function". when I compile it there is no apparent errors, but when I try to use the DLL in a VI, an error appears.
If I change this code and the input is made "manually" (using the VI) there are no errors. So I think that problem is in the way that Labview consider "fopen" function when I build a DLL. The "num.txt" file, where the data input are, is on the same directory that dll file and VI file.
I hope that you can help me with this problem.
Thank you very much in advance and please sorry for my bad english
Best Regards
Juan Crespo
Attachments:
foo_wrapper.c 2 KBDear Juan Crespo,
normally I don't answer questions concerning Matlab because I have no experience with it. But your question was waiting a long time and had to do something with DLL I decided to look at it.
Your C code has a serious error. You are declaring a variabale named "in1" as "double *". You do not set this pointer to point to a variable. Then you use this uninitialized pointer in the fscanf function to read in from the file. The value is written somewhere in the address space at a place where "in1" is pointing randomly. This will cause an error or crash.
Declare "in1" as "double" like you have declared "out". You must change some other places where you have used "in1".
Waldemar writing from Germany
Waldemar
Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions -
How to use a Matlab Program within Labview
Hi
I saw in this forum that many users are using some matlab program
executed in Labview program. I have actually Labview 7.1 and would like
to use some of my matlab program in Labview. Is there an easy way to do
it ?
Thanks
ThomasThe MATLAB Script function is kinda buried in the function palette, and
can be found under Functions >> Analyze >> Mathematics
>> Formula. Unfortunately this feature is not available in
the LabVIEW Base package. Hope this helps!
Andy F.
National Instruments -
We collected data using NI in the Labview environment and created tdms document. Is there a reader for reading the data in Matlab environment?
A search will often turn up results.
Reading TDM/TDMS Files with The MathWorks, Inc. MATLAB® Software -
MATLAB and LabVIEW Communication Optimal Performance
I have tried my own code, searched through forums and examples to try and figure out best method to communicate between LabVIEW and MATLAB. Most of the information I found was over a year old and I was wondering if there was a better current solution. My goal is to work in LabVIEW to collect the data, process in MATLAB and return the results to LabVIEW. I have encountered some difficulty in my search and before I delve even further in to one in particular, I was wondering if anybody had an optimal solution with this communication protocol or solutions to my errors encountered thus far.
I have looked at the following methods.
1)TCP/IP and a very good example found here: http://www.mathworks.com/matlabcentral/fileexchange/11802-matlab-tcp-ip-code-example
When I try to adjust even the example and communicate for my own purposes I get the following errors
Error 63 if MATLAB server not running
Error 66 occurs if the TCP/IP connection is closed by the peer. In this case, Windows notices that no data is returned within a reasonable time, and it closes the TCP/IP connection. When LabVIEW attempts to communicate after Windows closes the connection, error 66 is the result.
However, the example itself works perfectly and does not get these errors
2)Math Script Node, works but the post below states that MATLAB Node is faster.
"computing fft of a 1024x1024 matrix ten times (attached code). Result is that Matlab node version takes 0.5s versus 1.6s for Mathscript node version."
http://forums.ni.com/t5/LabVIEW/Why-are-mathscript-performances-much-below-matlab-s/m-p/2369760/high...
3) MATLAB Node, which states it uses ActiveX Technology seemingly works well, but loses time for data transfer.
4) Trying to use the ActiveX functions or if there is other Automation potential.
5)Other solutions that I have not found that might be better suited.
Thank you for any help or suggestions in advance.Barp and Mikeporter,
Thank you for your assistance:
The reason I need to do the processing in matlab is as you mentioned the processing script is coming from another person who has already developed it in matlab. I almost have to treat it as a black box.
The TCP/IP method was interesting is that none of the errors show up when I run the example but if I try to modify it in a new VI I get the errors.
I have attached a simple program that just has a basic butterworth low pass filter I am trying to confirm if it works in the Matlab node. I have done other simple codes which work, and this one does not seem the implement the appropriate filter. The LabVIEW signal and LabVIEW filter seem to work at the default values (but not if I change sampling rate) for the Simulation of signal, Matlab signal and Matlab filter work, but the Labview signal processed in Matlab is not working...
Ideally it would be bandpass filtered (0.1-30) at sampling rate of 256 Hz and further processed from there, but I can't even seem to get low pass to work in the matlab to labview communication.
Any help would be greatly appreciated. Once I have that working I will have more of an idea of the constraints of the actual processing Matlab Code I will be using.
Thank you again.
-cj18
Attachments:
labview_matlab_filter.vi 70 KB -
So, I search the binary matlab file format('*.mat').
Title:
Moving Data Between MATLAB® and LabVIEW
Problem:
How can I share data between LabVIEW and the MATLAB environment?
Solution:
MATLAB users can move data between the
MATLAB environment and LabVIEW, you have several options. Prior to
LabVIEW 5.1, the only way to transfer data between these two
environments was to use the Save and Load functions. Those are discussed herein.
Beginning
in LabVIEW 8.0, MathScipt was introduced. MathScript is an integrated
part of LabVIEW that you can use to combine intuitive graphical
dataflow programming with math-oriented textual programming. See the
attached links below for more information on MathScript.
Beginning
in LabVIEW 5.1, the MATLAB script node was introduced into the LabVIEW
programming environment. The MATLAB script node makes ActiveX calls to
the MATLAB software from within LabVIEW. This requires that both MATLAB
be installed on the same machine and that a valid license is obtained.
More information on the MATLAB script node can be found in the attached
KB's.
For all versions of LabVIEW, this data transfer can be
performed by saving the data in a file using the MATLAB software and
reading it directly from LabVIEW, or vice versa. In the MATLAB
environment, the command "save" allows you to save the data in
binary format (*.mat) or ASCII format. You also have an option of
saving it in ASCII format using a tab delimiter between data points and
the command "load" allows you to read in the data.
ASCII Format
Complete the following steps to import or export data between LabVIEW and the MATLAB environment using an ASCII file format.
From the MATLAB environment to LabVIEW
To save a vector or a matrix X in tab-delimited ASCII format, enter the following in the command window or m-script file in the MATLAB environment:
>>SAVE filename X -ascii -double -tabs
This creates a file named filename containing data X in tab-delimited ASCII format.
Import the file into LabVIEW using the Read From Spreadsheet File VI located on the Functions»File I/O palette.
From LabVIEW to the MATLAB environment
To export a matrix X from LabVIEW to the MATLAB environment, first save the data in ASCII format in LabVIEW using the Write To Spreadsheet File VI on the Functions » File I/O palette.
Enter the following in the command window of the MATLAB environment, or in the m-script file:
>> LOAD filename
This reads the data into the MATLAB environment.
Binary Format
Complete the following steps to import or export data between LabVIEW and the MATLAB environment.
From the MATLAB environment to LabVIEW
As mentioned above, LabVIEW does not save multiple variables to one
data with extra manipulation, and will not be discussed here.
Therefore, the only way of sending the data from the MATLAB environment
to LabVIEW without tampering with the MAT binary file structure is
using the ASCII format. Also, please bear in mind that you need to have
one file for one variable.
From LabVIEW to the MATLAB environment
Because
the MATLAB software saves data in its own binary format, the "MAT"
file, binary LabVIEW data must be converted to this format prior to
transferring the data. The attached examples can be used to save
LabVIEW data in the MATLAB software format. The convenience of the .MAT
file format is that more than one variable can be saved in the same
file. The example shows saving seven variables to .MAT format; the
example can be modified for any number of variables.
Once this data is saved from LabVIEW, it can be read into the MATLAB environment, using the following command:
>>LOAD filename
The Who
command can then be used to display all the seven variable names, and
you can display the content of them by entering the variable names at
the command prompt as usual.
MATLAB® is a
registered trademark of The MathWorks, Inc. Other product and company
names listed are trademarks and trade names of their respective
companies.
| Michael K | Project Manager | LabVIEW R&D | National Instruments | -
How to use a MATLAB license with password peotection?
I am using a MATLAB network license, which is password protected, so when I use a MATLAB script node LabVIEW can't load the proper MATLAB license and fails.
How can I submit the username+password info to LabVIEW?Hello malosh,
Unfortunately the functionality is not in place for LabVIEW to pass your username and password into MATLAB for you. Is it possible to log into MATLAB and then run your LabVIEW application?
If none of these suggestions help, or if I�m not correctly understanding your issue, please reply with comments or answers to the discussion above and any additional information that may help, and I�ll be happy to look further into it.
Have a nice day!
Robert Mortensen
Applications Engineer
National Instruments
Robert Mortensen
Software Engineer
National Instruments -
Can I use IF-RIO with LabVIEW 8.20
I am going to upgrade my LabVIEW to 8.20 but I am not sure whether the driver of IF-RIO can work with it properly.
Does anybody know this?Hi,
My customer get problems when using PCI-5640R in LabVIEW 8.2, but they could work in LabVIEW 8.0. Is there any latest NI-5640R driver support LabVIEW 8.2? Or PCI-5640R only works in LabVIEW 8.0?
Operation system and environment:
LV 8.2
LV FPGA 8.2
NI-5640R 1.1
NI-RIO 2.1.3
Display error message in LV 8.2 FPGA complier server.
An internal software error has occurred. Please contact National Instruments
technical support at ni.com/support with the following information:
Error 1003 occurred at Open VI Reference in
nirviGetModInfo___nirviEIOImplementation_modGen.vi->nirviGetModInfo___nirviE
IOImplementation_modGen.vi.ProxyCaller
Possible reason(s):
LabVIEW: The VI is not executable. Most likely the VI is broken or one of
its subVIs cannot be located. Open the VI in LabVIEW using File>>Open and
verify that it is runnable.
VI Path: C:\Program Files\National Instruments\LabVIEW
8.2\resource\RVI\StockIO\private\StockFPGA_io_modGen\nirviGetModInfo_StockFP
GA_io_modGen.vi
Please refer the attached reproducable example code.
Best Regards
NITW AE
Gary
Attachments:
UsingFilterCore.vi 550 KB
filt20070509104003.zip 255 KB -
bonjour à tous et merci d'avance ,
je cherche un lien(ou bien une idée) pour télecharger le toolkitmatlab compatible avec labview 2011 (sinon 2009).
l'objectif c'est que je veux transformer un code matlab vers labview.
merci les ingénieurs du ni et tout les membres de forum.
amicalementHi khadija,
You should be able to find the 2011 version of the mathscript-RT toolkit on ni.com/downloads. The download site has recently undergone a lot of changes and the search may not be up to speed yet. A direct link to the 2011 mathscript-RT toolkit is here: http://joule.ni.com/nidu/cds/view/p/id/2558/lang/en.
However, it sounds like you are using Matlab toolkits. The mathscript-RT toolkit re-compiles .m code into labview source code. However, the mathscript-RT toolkit will not work with any of the Matlab® toolkits, such as a vision processing toolkit. A list of commands the mathscript node can use is given here.
You also might try using the Matlab Script node, which is separate from the Mathscript-RT node, the Matlab Script node uses activex to call into the Matlab runtime engine. It should be able to utilize any toolkits that the mathscript-RT toolkit can't. However, the Matlab Script node will be slower and will require an installation of Matlab on each computer that your application runs on.
MATLAB® is a registered trademark of The MathWorks, Inc. Other product and company names listed are trademarks and trade names of their respective companies.
Jesse Dennis
Design Engineer
Erdos Miller -
Integrating matlab into labview
Is it possible to integrate (import) a matlab file which uses special toolbox ( like hmm toolkit and neural network) into LabVIEW??
When you say "one motor is connected to one matab file" - do you mean one .M file, or a MAT file ? In other words, is it a program or data?
The easiest way that I"ve come across to transfer data between different environments, is to write to an intermediate file. Be sure to write to a raw binary or text (dont use the Matlab 'save' command, that will save in MAT format, which I'm pretty sure is unreadable by LabVIEW). There is the problem of signalling the LabVIEW program when data is available, you could handle this by having the Matlab program could write to another file to indicate that data is availalbe, and the LabVIEW program could continuously poll this file to see if a value has been written. Then the LabVIEW program would read in the data file, and reset the signalling file. -
Connecting JADE &MATLAB with LabVIEW
I wish to Connect JADE and MATLAB with LabVIEW,. Please provide the relevant documents.
For matlab, there is the matlab script node.
For JADE, you need to be more specific, because there are several programming tools with that name (e.g. here or here).
You need also define what you mean by "connect". In the most general case you would simply build a dll in the other language and then call it using the call library function node.
What are you actually trying to do?
LabVIEW Champion . Do more with less code and in less time . -
How do we use if statement in labview?moreover can i use if statement inside for loop?
how do we use if statement in labview?moreover can i use if statement inside for loop?
The if statement in LabVIEW is the Case structure. You can find that on the Structures palette right next to the For Loop. If you're still on the same subject about terminating a for loop early, then what you do is enclose your functions inside the loop with a case statment and make one of the case's empty except for one or more constants that you might have to wire. Hopefully, the attached picture will explain what I mean. Also, as I mentioned in one of your other posts, I think this technique is not as good as using a while loop. The array in the attached example is the same size no matter what and you may have to handle stripping extra or invalid elements.
Attachments:
For_Loop_with_Case.jpg 21 KB -
How to implement a dual booting PXI system using windows 7 and labview RT
Good Day
My name is Mariano Ocana from the University of Manitoba, and I want to implement a dual system using windows 7 and labview RT in a PXIe-1082 chassis with a PXIe-8102 embedded controlled (the chassis came with windows 7 installed). What are the steps to use both systems (windows and RT) in the same chassis?, in the NI help comes an example implementing a dual system using windows xp and RT, it is the same procedure?.
Thank you in advance for all your help.
Regards
M. OcanaGreetings, Mariano.
The real issue you have to contend with is whether or not you have a LabVIEW RT license. If the 8102 controller was purchased Windows-Only, you likely do not have a license to run LabVIEW RT on the controller - you can purchase one, I think it's about $500, and at that point you can request a LabVIEW RT Configuration CD (that's not what it's called, but the sales guy will know what I'm talking about). The Config CD is a CD that will partition your controller correctly with both FAT32 and NTFS filesystems (in the appropriate way) to allow you to run Windows 7 and LabVIEW Real-Time on the controller correctly. Once done, you can then switch within the BIOS between LabVIEW Real-Time and Windows in order to dual-boot.
Either way, you likely need to contact NI sales to either purchase an RT license (if one was not received at the time of purchase) or to request a Configuration CD (it might also be called a dual-boot install CD or similar).
-Danny -
Getting the data in file using DAQ assistant in Labview
I am using SCXI 1000 chassis, SCXI 1125 input module and SCXI 1320
terminal.
I am using DAQ assistant in labview to obtain temperatures and store it in
a file. The experiments run the whole day and I need the whole data
generated during this time to be stored in a single file, but I am unable
to store it in a single file.
Can someone please give me some insight as to how can I achieve this?Hi Mr,
It would be helpful to see your code to see exactly how you are acquiring the data. Are you doing continuous buffered measurements? Or are you performing single point temperature measurements in a while loop?
Either way you will want to use the "write to spreadsheet" VI in your loop. Simply wire your data into the "write to spreadsheet" vi and se the "append to file" input to TRUE. This will make the data add on to the end of the file with each iteration of the loop. The "write to spreadsheet" VI is located in the file IO pallette in LabVIEW.
Thanks,
Sal -
Build a DLL in LabVIEW & Use the DLL in LabVIEW
I am trying to build a DLL for the simple vi with LabVIEW and want to use the DLL in LabVIEW. is it impossible?
I wrote a vi and it have 2 terminals. one is the input for numeric dbl data type and one another is the output for numeric dbl 1D array data type.
It was built with the Application builder for LabVIEW 8.0 and DLL was created successfully.
I want to use this DLL in new vi with LabVIEW.
Call library function used. I wrote a new vi to use that DLL.
In config dialog I config each parameter for dll and connected terminals. but it doesn't work
pleas refer to the attatched file and let me know what I missed.
Attachments:
Array1D.zip 60 KBAt first I kept scratching my head wondering why someone would want to do this. Create a DLL in LabVIEW to call it from LabVIEW. Seems redundant. But, perhaps it's an exercise or perhaps it's for testing the DLL...
In any event, calling the DLL worked for me in 8.2. How are you configuring your Call LIbrary Function node? I have it set up as follows:
return type: void
iteration: Numeric, Signed 32-bit Integer, pass by value
array1D2: array type, Signed 32-bit Integer, 1 dimension, "Array Data Pointer" format
len: Numeric, Signed 32-bit Integer, pass by value
Then I called the DLL like this:
Message Edited by smercurio_fc on 03-16-2007 12:57 PM
Attachments:
Example_BD.png 2 KB
Maybe you are looking for
-
Connect problem with db link and scheduler_jobs on 10.2.0.4.0
hello guys i have got this problem, i hope someone can help me to understand and solve it. I have a pl/sql procedure where is referenced a table on a db_link. I own all the grants needed, and if i recall it in an anonymous block, it seems to work. i.
-
How can I set a value to an Object Array
I am declaring an object variable like this: final Object[][] data = { {"Mary", new Integer(5)}, {"Alison", new Integer(3)}, {"Kathy", new Integer(2)}, {"Sharon", new Integer(20)}, {"Angela", new Integer(4)} And I would like to declare it like this:
-
NoclassDeffound error while accessing the application through agent.
Hi All, I have deployed FAM 8.0 on glassfish and configured successfully with Sun one Directory Server 5.2 . I have created another domain called domain2 on glassfish and installed j2ee agent on that domain to protect a sample application hello throu
-
Hello...I have yet to receive an answer that resolves the problem. I regret buying the printer because now it doesn't work. The error message remains despite taking advice how to fix it. We only use the black cartridge. Can anyone suggest another ma
-
Is there a short/hotkey to show/hide bookmark toolbar?
I would like to have in options>bookmark toolbar unchecked, and a hot key or shortcut key to show or hide the bookmark toolbar. Having it checked takes room, and the autohide mouse hover addons get annoying when your going type in the URL bar and not