LabVIEW MathScript RT Module

cancel
Showing results for 
Search instead for 
Did you mean: 

Newbie having trouble defining user function

I have a function compiled & save in the search path :
function a = deg2rad(x)
% converts degrees to radians
a= x*pi/180
 
 
When I try to run it I get :
 
The current MathScript was compiled successfully.
>>b=deg2rad(45)
Unknown symbol on line 1: deg2rad
 
Can someone help?
0 Kudos
Message 1 of 4
(7,286 Views)
Hello,

There is nothing wrong with the syntax you wrote as I am able to make it work here.  However, there are a couple of things to try:
  1. Ensure that the file is located in the current MathScript search path.  In the MathScript window, type "path" and "pwd" (without quotes).  Is the directory in which you saved your function listed in the output of one of those two commands?
  2. Is the filename you gave to your function the same as the function name?  LabVIEW MathScript requires that the two be the same.  In your case, is the file saved as deg2rad.m?
Grant M.
Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments
0 Kudos
Message 2 of 4
(7,279 Views)
Thanks - it was in the wrong search directory
0 Kudos
Message 3 of 4
(7,274 Views)
By the way, if you wish to change the default search path for MathScript, go to File >> MathScript Preferences in the MathScript Window.  If you only wish to change it for one time, you can use the path (or addpath) command.  This will affect both the MathScript Window and the MathScript Node.

Grant M.
Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments
0 Kudos
Message 4 of 4
(7,270 Views)