08-16-2010 04:31 AM
hi iam stuck in middle
i want to use math script & call the matlbfunction which i wrote in matlab
but my vi showing this error
Error in function ip at line 2. The indexes are out of bounds for the variable you specified.
i have attached the file
what eror iam doing in that
thanks
08-16-2010 07:21 AM
Same as this thread:
08-16-2010 08:44 AM
Hello,
Your input variable ip is a scalar. The problem is that you are trying to index ip on line 2 (which is actually the first line of your code since line 1 is an empty line). When you try to index the second (or later) element out of ip, an error is returned since a scalar only has one element. Change your input variable to a vector and you should be all set.
One thing to note is that you have many statements on each line of your script. If you split the first couple lines of your script after each semicolon, you will have only one statement per line. This can make debugging easier.
Grant M.
Senior Software Engineer | LabVIEW MathScript | National Instruments
08-16-2010 10:37 AM
Hi,
GrantM
thanks for ur replay
plz check my attached file
this is function which i have wrote in matlab 7.9(r2009b) , which is matlab function whom iam calling in simulink model in matlab & it is working well
same thing i want to implement through labview(iam using labview 8.2) by using math script node
as in simulink i just write the name of function & it call it(the matlab function..
so could u se my attached file & suggest me could iam doing in right direction ..
or could u give me an example of my program
i have already read the examples on math script function how it work?
as u mentioned i could used ip as vector? is any direct way in labview to change numeric control of scalr to vector .. as in intial question
thanks in adnace for ur cooperation
tc
08-16-2010 01:22 PM
Hello,
I only had to make a few changes to get your file to work. First, rename your myfunction.txt to myfunction.m. All MathScript user-defined functions must have a .m extension. Second, place this .m file in your "My Documents\LabVIEW Data" directory. This is the default search path where MathScript looks for user-defined functions. Third, make sure the function has the same name as the file. I had to change it from "myimplement" to "myfunction" since the file is myfunction.m. Finally, remove the end statement from the bottom of the function. Although the end statement is optional in a function definition, explicitly using it is a bug in MathScript.
There is not a direct way to change a scalar control to an array. But all you need to do is drop an empty array control on the front panel and move the scalar control into it.
Grant M.
Senior Software Engineer | LabVIEW MathScript | National Instruments
08-16-2010 06:13 PM
Hi
i have done all that u have mentioned in ur reply
rename file name as myimplement.m put it into C:\Documents and Settings\User\My Documents\LabVIEW Data
nd have remove the end statement
but again the same problem it is nt working
could u plz explain me by example
iam trying to do it
thanks a lot
tc
08-16-2010 08:18 PM
Please post your actual VI. Do not post screenshots. Do not post Word documents that have screenshots embedded in them. Do not post scripts. Post actual LabVIEW code.
Also, please try to use full words instead of "Twitter-speak".
08-17-2010 01:48 AM
hi
ok iam attaching my vi
please check& see the error
at home iam having older version of labview 8.2 it is showing this error
Error 1046 occurred at LabVIEW: LabVIEW cannot initialize the script server. Ensure the server software is installed. in implement.vi
but if u copy it to new version it shows the error of index out of bound?
b/c iam using input as scalar , unless my input('ip) which is vector ? so as in my previous how i can change it into Array input?/
thanks if any one can solve my issue
08-17-2010 09:43 AM
You need to pay more attention to what people are telling you. You are trying to use the XMath node. This is not the same as the MathScript node which is what Grant was telling you he was using, and the instructions he gave you are for that.
b/c iam using input as scalar , unless my input('ip) which is vector ? so as in my previous how i can change it into Array input?/
You right-click on the input and using the pop-up menu you specify the data type. This is explained clearly in the LabVIEW Help.
08-18-2010 01:04 AM
hi
how are u
ok iam attaching my vi
the error is
Error in function ip at line 7. The indexes are out of bounds for the variable you specified.
where iam going wrong
i have kept my function file imlement.m in same library
C:\Documents and Settings\IAA\My Documents\LabVIEW Data
how i will sor out that problem
iam attaching my .m file also, which i want to implement through math script node
thanks if any one can help me out regarding my problem
take care