LabVIEW MathScript RT Module

cancel
Showing results for 
Search instead for 
Did you mean: 

erf function inputs not clear

Solved!
Go to solution
Highlighted

Hi all,

 

in the description in this link http://zone.ni.com/reference/en-XX/help/370051Y-01/cvi/libref/cvierf/

it is öentioned that the erf function Erf (double x, double *erf) has 2 inputs.the second input should be an array of double but what exactly represents this inpt to the function because as far as i know erf in matlab have only one input.

Any explications please.

 

0 Kudos
Message 1 of 8
(3,653 Views)
Highlighted

You are looking in the wrong place...

 

This function you showed is documentation for LabWindows CVI:

http://zone.ni.com/reference/en-XX/help/370051Y-01/cvi/libref/cvierf/

 

However, you should be looking at this document:

http://zone.ni.com/reference/en-XX/help/373123B-01/lvtextmath/msfunc_erf/

 

In this documentation, the function is y= erf (x), as you would expect.

Barp - Control, Simulation, RTT and HIL - National Instruments
0 Kudos
Message 2 of 8
(3,649 Views)
Highlighted

Hi Barp,

 

Actually, I am working in labview communications design and not labview so the "erf" function is not defined in the C node.

I searched the erf function in this link http://www.ni.com/documentation/en/labview-comms/1.0/c-ref/analysis-lib/

and it directed me to Labwindows CVI.

7.PNG

as you can see the error.Any other suggestions please ?

Thanks,

0 Kudos
Message 3 of 8
(3,620 Views)
Highlighted

@emnajaoua wrote:

Actually, I am working in labview communications design and not labview so the "erf" function is not defined in the C node.

 


So why did you post this in the LabVIEW Mathscript RT forum? This discussion probably belongs over here.

 

You can ask the moderator to move this thread.


LabVIEW Champion. It all comes together in GCentral GCentral
0 Kudos
Message 4 of 8
(3,612 Views)
Highlighted

Hi,

 

I have already asked the question there but no luck so far.

also the "erf" function belongs to the mathscript RT module as I know so I wanted to search for a solution.

0 Kudos
Message 5 of 8
(3,603 Views)
Highlighted
Solution
Accepted by topic author emnajaoua

For this product you are using (which you did not say, but looks like LabVIEW Comms , Erf function is not supported in Mathscript or as G-code.

 

Now you can try this code:

 

 a1 =  0.254829592;
 a2 = -0.284496736;
 a3 =  1.421413741;
 a4 = -1.453152027;
 a5 =  1.061405429;
 p  =  0.3275911;

s = 1;
if (x < 0) 
   s = -1;
end
x = abs(x);

 t = 1.0/(1.0 + p*x);
 y = 1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x);
    
y= s*y;

I converted from here: http://www.johndcook.com/blog/cpp_erf/

 

By the way, this code could also be easily integrated using C-node too. 

 

Now, most likely Erf function will be available in future versions of LabVIEW Communications System Design.

 

 

Barp - Control, Simulation, RTT and HIL - National Instruments
Message 6 of 8
(3,599 Views)
Highlighted

Hi Barp,

 

I am sorry for not being that clear.I have tried your solution in the C node but its outputs as not correct (I don't know why by the way).So I have tried the same script in the mathscript node using this http://www.mathworks.com/matlabcentral/fileexchange/55749-error-function-stand-alone/content/erf_sta... and it seems to work.

 

Thanks for the solution .I missed the idea to search for a standalone function.

 

Best Regards,

 

Emna.

 

 

0 Kudos
Message 7 of 8
(3,591 Views)
Highlighted

yes... I forgot that Mathscript requires ".*" if x is a vector. This is just natural as G-code...

 

Anyway, I am happy you have a solution until we have this function available for you.

Barp - Control, Simulation, RTT and HIL - National Instruments
0 Kudos
Message 8 of 8
(3,568 Views)