Problems of integrating Matlab functions in Labview
Hi,
Does anyone know how to completely integrate Matlab functions into Labview program without a copy of Matlab in the system when I run the entire program?
Initially I used 'Mathscrip' node but I heard that it doesn't support Matlab toolbox. Thus, I tried out the other option 'Matlab script' node. This node works well in implementing Matlab functions but it indeed requires Matlab installed in the system.
So in other words, how could I realize the full integration(as what Matlab script node achieves.) without Matlab installed in the system?
Cheers,
Nicholas
hi smercurio,
So you mean that the Matlab script is no longer necessary in my case right?
Could I just ask my colleague to compile his codes to matlab dll and I use the Call Library Function Node instead of Matlab script to call it?
About MCR, is it the correct source at the following link http://www.mathworks.com/matlabcentral/fileexchange/5268 ?
Sorry for those basic queries in Matlab as I have very little experience in it. lol... thanks a lot.
Cheers,
Nicholas
Similar Messages
-
Some problems using some Matlab functions
Hello,
I have some trouble with MathScript when i want to use some MATLAB functions in it such as unique or histc. (i'm using windows 7 and LV2010 SP1)
These functions are theoretically supported by MathScript insofar as they exist in MathScript Documentation but they return an error. This error explains that my matrix sizes are invalid but when we are doing exactly the same process with the same matrix in MATLAB, it ends well.
So I checked the two MATLAB and MathScript documentations in order to see if there is a difference between the same functions. It is proving to be the same functionning in MathScript and in MATLAB so I am a little lost.
In order to show you a concrete example :
If we have a X matrix equals to (77 77; 88 96) and we are doing unique(X). The result is supposed to be (77 88 96) but mathscript returns an error.
On the other hand, if X is not a matrix but a vector, unique ends well but i'm not interested in using some vectors (because it is exactly the same kind of problem with some others functions using only matrix).
I could use a matlab node script but in this project, we would to avoid the use of a Matlab Licence.
Do you have some idea in order to fix this kind of problem
Thanks a lotHi,
Currently, the unique(X) in MathScript can accept vector input only. It reports error when X is a matrix. As a workaround, you can use
unique(X(:))
instead. -
How to use matlab function with labview?
Hello,
I just want to use some matlab functions like floor(),ones()... in my labview code, who can tell me how to do it?
I want to only install MCR in my PC, so MATLAB script node can not work because it need matlab installed.
Thanks
Solved!
Go to Solution.floor() exists on the standard labview pallet already and the ones() function would be fairly simple to reproduce. If you only need a few basic functions repost asking for direction on recreating those specific methods. However, you're right - there is not a direct way to use compiled matlab code in labview without full matlab and the math script nodes. If you're really desparate to reuse some some exisiting IP there are C++ alternatives that implement many of the same methods and syntax as matlab (http://arma.sourceforge.net/faq.html). I'm fairly sure there are other tools that attempt to translate matlab code into pure c functions, both of which can be called via a DLL from within labview: https://decibel.ni.com/content/docs/DOC-9076
Alternatively, here is an all NI linear algebra solution: http://sine.ni.com/nips/cds/view/p/lang/en/nid/210525 -
Error running MATLAB function on LabVIEW (it works on MATLAB)
Hello,
I want to run a game (that I did not write) in LabVIEW which is all programmed using MATLAB. It runs on MATLAB but I have no clue why it does not run on LabVIEW. Please take a look at the attachments to see the error, VI and game.
Note: I tried running other simpler .m functions that also call outside functions in the same folder using the same VI and they work so it is not the MathScript Node. Also, I already changed the search paths for the MathScript Node therefore the root of the problem is not there either.
Thank you!!Hello,
When using the MathScript RT Node you should enter your m code into the Node itself. Have you tried taking your code from the Missile Commander file and putting it in the node? Are you using any funtions that are on the unsupported list?
Below are a few resources on getting started with the MathScript Node.
Getting Started with the MathScript RT Module
LabVIEW Help: MathScript Node
MathScript RT Module Functions
MathScript Functions Not Supported in the LabVIEW Run-Time Engine (MathScript RT Module)
-
How user define matlab function will work in labview
Hi all
iam trying to implenet the matlab function which i have wrote in Matlab 7.9(R2009b)
function [ op ] = myimplement( ip )
the file is attached below
i want to use matlab function in labview ,i have tried Matlab script node but few of function define in matlab function are not working properly
so is any alternative way to implement matlab function in labview environment to implement my algorithm & getting same results
thnaks
waiting for kind reply
iam trying from many days but not geting any results
Attachments:
myimplement.zip 2 KBHi smercurio_fc nd sry if u mind my double post actually iamin last month of my post graduate research so i want to complete it urgently
iam attaching detail file what iam facing?/
same thing iam doing in Matlab & getting result but while doing in Labview by using Matlab script node not getting
error 1048 is occured
iam attaching word file kindly help me out regarding that problem
i will be thankfull for u
tc
Attachments:
my matlab function.docx 134 KB
my matlab function.doc 154 KB -
How matlab function is work in labview
hi all
i have implenet a function say
function [op]=myimplement(ip) in Matlab
& i have used it in simulink as Matlab function
as i have attached the both matlab file name & also Simulink file
i want to convert the matlab function int Labview
i have tried by using Matlab script node
but its is not working ??
so where iam doing any mistake??
iam also attaching Labview file as well name funct.vi
waiting for any kind replay
thnaks
Attachments:
prog.zip 10 KB
funct.vi 13 KBAs it is the Matlab node can't really do anything with that. It would be no different than if you have a .m file. You need to call the function. The Matlab node does not do that automatically (and neither does the Matlab editor). Of course, it's probably simpler to just remove the "function" line and have the last line changed to say
uk=[x_ukp1;x_ykp1;x_zkp1;thetakp1(];
instead of
op=[x_ukp1;x_ykp1;x_zkp1;thetakp1(];
Note: I believe your input variable should be "ip", not "n", since you calculate "n" in the script. -
Relations between Matlab structures and LabVIEW clusters
I have a DLL created with Mathworks COM Builder, used as an ActiveX component in LabVIEW. Thus, I am able to have my Matlab functions inside LabVIEW. However, I have a problem regarding the pass of parameters between Matlab and LabVIEW.
When the Matlab functions parameters are simple -DBL, DBL arrays, strings-, there is no problem. LabVIEW does the right translation. But I have not been able to pass a Matlab structure to LabVIEW, which counterpart I think it would have to be a cluster. To solve this situation I need to split the structure components and pass them separately.
Does anyone know how to do it without the workaround?
Thanks in advance and have a good day,
spjHello Tishu,
1) Can we use nested for loop in Mathscript node?
1) Yes you can. Remember that loops should be avoided as much as possible in m-scrips. Most of the times you can use vectorization to represent same task.
2) Which one of these is feasible: 1) Matlab script node
2) Mathscript node
2) What exactly is the "Feasable" question? Real time (see below) or nested loops (see above)
3) Is there any other way to interface between matlab and LV for real time signal processing?
3) Real time is different depending the application. Some applications need ns or ps real time (RF appls) others need seconds delay. Real time means "determinism". That a task will execute in a know time with little jitter. Windows is not a real time OS therefore nothing in it will operate in real time. Can you tell us something about the signal your are processing (Audio, Image fps, Radar)?
4) Suppose X is 1D array (DBL) in Labview. And Mathscript code is as below:
For i=1:inf, 4) Is this vector a valid one? inf = Inf which is different from 1/eps.
Y= X-1;
end
Here X is input and Y is output.
Such code does not produce output (Y variable) in real time processing.
Does it wait till the FOR LOOP ends? Is there any solution to such problem? 5) What is this suppose to produce?
Let me know,
yardov
Gerardo O.
RF Systems Engineering
National Instruments -
I have some software problems of running matlab script node in the LabVIEW program.
Hi there,
I wrote a simple matlab code, like x= 1, y = x*2. Then I tried to put them into matlab script node in LabVIEW.
However, when I ran the program, I couldn't run and Labiew show some error.
Then I tried the method talked before on this forum. Please see the following link.
http://forums.ni.com/ni/board/message?board.id=MathScript&thread.id=571
I followed the instruction and open the "command prompt," type some commands then I could run the program, and simultaneously, the LabVIEW program open "Matlab command line window" and run my labview code. However, if I didn't use the command prompt, the "matlab command window" will not be opened by running the labview program. It would just show some error. And even if I turn on the matlab program in advance, I still couldn't run the labview program.
Is there any effecient way to deal with this problem without using "command prompt?" Because I try another PC with both matlab and labview installed on it, I "can" run my simple matlab script node on it, and it will open the matlab command line window automatically by running my code. Therefore, I thought there might be some software linking problems in the previous PC I used . Do you have any ideas?
Thanks in advacne.This board is for Mathscript, but you seem to have a matlab problem. You should probably post in the LabVIEW forum instead.
What is your LabVIEW version? What is you matlab version?
LabVIEW Champion . Do more with less code and in less time . -
Different output of DST function in labview and matlab
I am passing a 1D array of size 1550 as input to DST function. I have also calculated DST of same array in matlab using 'dst' function. I got approximately same answer till 1399th element but after that answers of two varies abruptly. I tried hard but I am unable to find the solution. I am attaching the data file in which it can be clearly seen that at 1530th element there is a difference of sign also.
Attachments:
data file1.txt 37 KBOut of curiosity, have you tried another software, like Octave? When you have two software that is different, which one is incorrect?
Also, have you tried to use the DST function in LabVIEW directly?
Another think to keep in mind... When you try to run a sequence for so long, small round-off errors could be cummulative and show later on the analysis. Also, it depends on how you load the data into each software. Hopefully when moving the platforms, the string conversion would not truncate the number. The best is not using string, but some kind of binary format...
These are some ideas to check...
Barp - Control and Simulation Group - LabVIEW R&D - National Instruments -
Is it possible to access Matlab functions (m-files) in Labview.
Is there a dll that fixes the problem?
I don't know how to calculate feedback gains using the lqr-algorithm and
kalman and that sort of stuff...
Thanks
ToonUnder LabVIEW 5.1 and higher, there are a number of excellent additional
Mathematics functions built into the palette, including a Matlab script formula
node. If you've got LabVIEW 5.1 under 32-bit Windows, you can simply pop one of
these nodes down on your diagram, right-click it to import your m-file, and
you're all set.
Depending on your OS and your versions of LabVIEW and Matlab, there will
probably be additional possible ways to communicate between the two
applications, but if you're doing a lot of Matlab integration, LabVIEW 5.1 is a
good investment.
Regards,
John Lum
National Instruments
Toine wrote:
> Is it possible to access Matlab functions (m-files) in Labview.
> Is there a dll that fixes the problem?
>
> I don't know how to calculate feedback ga
ins using the lqr-algorithm and
> kalman and that sort of stuff...
>
> Thanks
>
> Toon -
Creating .mat files with Matlab dataplugin in LabVIEW
I am trying to create a .mat file in LabVIEW using the Matlab dataplugin. It appears to create a group called "Vector" without being told to, and it also concatenates group and channel names together. I have made an example to demonstrate this behaviour. I am trying to create a group called "Group" and inside it a channel called "Channel". What I get looks like a group called "Vector" and inside it a channel called "GroupChannel". What am I doing wrong?
Best Regards,
John Sackett
Solved!
Go to Solution.
Attachments:
write mat example.zip 54 KBHello John
Thank you for getting in touch regarding your issue. I am an applications engineer here at National Instruments, as I understand you are using the data plugin for Matlab within LabVIEW, but as shown with your code when you label the channel or group you get an outcome which you don't expect.
I have opened and had a look at your code and can see where the issue is arising. The functions you are using are normally used with TDM files, .MAT files are compatible but there are a few differences between the file formats, which is why you are getting the outcome we have seen. A TDM file has headers named channelgroup and channel, but Matlab does not have the channelgroup header in the file type and therefore the functions in LabVIEW merge the 2 strings to the available header.
I am not able to open your .MAT file so could you give me a brief description of what occurs inside Matlab?
Have you looked into using the script node to allow for .MAT file types in LabVIEW? Here is the help file
I have also found some resources which you may find useful.
LabVIEW to MATLAB
Convert file
Open .MAT in LAbVIEW
DataPlugin
Let me know if you would like any further information
Regards
Stephanie L
Applications Engineer
National Instruments UK and Ireland -
Memory problem using visa serial functions in my vi
The last few days i created an application that reads data from one of
serial ports (contactless card reader). Today i noticed that my
application had crashed and Windows had displayed a message that my
system was low on virtual memory. I reset the system and i re-run the
application, having the task manager opened. I noticed that the memory
usage of my exe was taking more and more memory (starting from
21.520KB) as the seconds went by. In 5 minutes my app was using
25Mbytes! What i do in my application exactly, is opening the serial
port then i enter the main while-loop, then every 2 seconds i read
from the serial and write them to a tag.
I have used standard visa serial functions of Labview. When I trace my
application and simultaneously run TASKManager of windows to see the
memory, I saw that after running every Visa function memory usage goes
up!!!
what must I do? Please help me to overcome this problem.
Thanks,
M.NaghipourfarTrust me, people use serial communication with LV all the time without losing memory. I can't check the example at the moment, but If it had a problem someone would have caught on to it by now. In any case, even if using the serial VIs causes the memory usage to go up, it shouldn't be dramatic, definitely not enough to crash the application and consume all memory.
Like I said, post your code (there is an attachment field when you write your message and you can save all your files into a single file by opening the main VI and selecting File>>Save with Options>>Development Distribution) and we will probably be able to find your problem.
To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).
Try to take over the world! -
Mathscript all matlab functions are not working
Hello,
I am using mathscript node in my labview development. I have used right away "imfill" function to fill the holes in my edge detected image. But the "imfill" function is not working in mathscript.
How could I use this function in mathscript?
Attachments:
Candel.vi 96 KBDid you take this code directly from MATLAB and put it in the MathScript node? (I'm guessing the imfill function is a MATLAB function?)
If so, you're going to be sorely dissapointed. While MATLAB and the MathScript node both use .m files, they are not the same language. The language is very similar, but the syntax differs slightly in some cases. My guess (since I've used MATLAB but never the imfill function) is that the imfill function is part of a toolkit for MATLAB. Unless the MathScript node has a corresponding function (you'd have to search the help to see) you will not be able to use this function in the MathScript node.
If the MathScript node has no corresponding function and you must use this function in LabVIEW, I would reccommend the MATLAB Script Node. This structure actually calls MATLAB through the ActiveX interface. This means that you must have MATLAB installed on the computer you are running your VI on.
Chris
Certified LabVIEW Architect
Certified TestStand Architect -
Same code gives different results in Matlab Script in Labview and Matlab
I am implemeting a Matlab code into a LabVIEW application using Matlab script. When I import the exactly same code to the Matlab Script in LabVIEW it gives a different result than it is in Matlab. This code is a simulation code including first kind bessel functions. Using LabVIEW 7.1 and Matlab R14 service pack 3.
Labview 8.5
Matlab R2009b
Attached are the graphs produced by matlab script in labview and in matlab.
The minimum of graph produced by matlab code is below 1 and that in labview is above 1.
Thanks a lot for your reply.
Sorry, I haven't quantified the "sometimes" yet.
Attachments:
matlabsResult.jpg 29 KB
LV.png 84 KB -
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
Maybe you are looking for
-
Portal Password Reset Application In webdynpro for ABAP
Hello Friends, I am new to WDA . I want to create a Password Reset application in WDA like this [http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0c09b9d-52e0-2d10-3981-86bfa8e19dc3?quicklink=index&overridelayout=true] Can someone
-
Unable to delete a custom report in Fabric Manager
Hi there, If I create a Custom Report in Fabric Manager (3.2(3a)) I'm unable to Delete it aftwards :-( Get an "Error on Page.": Line: 388 Char: 1 Error: 'Delete560nClick' is undefined Code: 0 URL: http:/xxxxxxx/s614.do Any ideas ? IE version I'm runn
-
My new IPad won't sinc with my IMac Intel Snow Leopard 10.6
Having issues getting IMac to see IPad. when plugged in I hear the notification, but my IMac does not charge the IPad or recognize that it is there. I am using Snow Leopard with my 2006 IMac Intel machine. Any suggestions?
-
Customisation of VSR (Vendor Sub-Range)
How we can customise VSR in SAP MM, can anybody suggest me?
-
Purchased CS6 FW-- Need to reinstall it. Please help
Hi My Fireworks CS6 kept crashing, and wouldn't open even after multiple reboots. I uninstalled it, meaning to reinstall it using my company's license. Please help! It's getting in the way of my work.