LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create an if else structure with different formulas.

Solved!
Go to solution

if else.png

I want to create an If esle structures that first evalutes the formula from the left block and if it is true than the formula of right above is done and if it is smaller the formula of right below is used? any suggestion

0 Kudos
Message 1 of 7
(3,725 Views)

This is very basic.  Have you looked in the comparison palette?  Have you used a Case Structure before?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 7
(3,711 Views)
Solution
Accepted by topic author shivik89

Calculate the right side. Compare to the left side. Send result to a case structure.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 3 of 7
(3,689 Views)

As crossrulz stated, the example equations in your post can easily be managed with comparison and a case structure.

 

If your decision tree is more complicated (or if you're dealing with more complicated equations) you can look into MathScripts.  This can prevent your block diagram from becoming unruly.

 

http://www.ni.com/white-paper/7572/en/

http://zone.ni.com/reference/en-XX/help/373123C-01/lvtextmathmain/mathscript_syntax/

 

 

Message 4 of 7
(3,687 Views)

Is the "far field" parameter one of the variables on the right side? Where does D, E, P come from?

 

Unless you have gigantic datasets, it might be simpler to just calculate both and use a select node to pick the result based on the comparison. All these calculations are very cheap and e.g. D² needs to be calculated always anyway. You can also pre-calcuate 1/377 and 1/(4pi), once before the loop, etc.

Message 5 of 7
(3,652 Views)

Thaks everyone I found a solution

0 Kudos
Message 6 of 7
(3,618 Views)

@shivik89 wrote:

if else.png

I want to create an If esle structures that first evalutes the formula from the left block and if it is true than the formula of right above is done and if it is smaller the formula of right below is used? any suggestion


You original question was solved, but IMHO your underlying physics is flawed.

 

The equation in the left block is a general equation to estimate at what distance the propagating wavefront surface emitted from a point source has constant phase. This equation assumes electrically large antennas (dishes, etc). "D" in this case is defined as the largest dimension of the source antenna. There are other equations for electrically small antennas that are usually based on the number of wavelengths (i.e., r >> 2*lambda).


The two equations on the right BOTH assume Far Field!! Neither equation will give you the correct results in the near field!!


The upper equation, E is the measured Electric Field intensity at the Receiving antenna. The Poynting Vector is  S = E x H. In the Far Field, H = E divided by 377 ohms (for free space). Substituting, you get: S = E^2/377.

 

The lower equation, is derived from the Friis transmission equation and again valid ONLY in the Far Field: where P=transmit power, G=gain of transmit antenna and "D" is the distance between the transmit/receive antennas. Many textbooks use "R" for that parameter to avoid confusion between "D" and "R".


So... your case selector should instead be

 

if you know "E"
          use first equation

else if you know the transmit power, anttenna gain, and range
           use second equation

else if you are in the Near Field
           Use Neither equation

Message 7 of 7
(3,597 Views)