Please enable JavaScript to view this site.

Knowledge Base

Starts an if statement. The scripting language supports if statements in the following forms:

 

Supported Product: FDTD, MODE, DEVICE, INTERCONNECT

 

Syntax

Description

if(x < 5) { y = x^2; }

Simple if statement on one line.

if(x < 5) {

y = x^2;

}

Multi-line if statement

if(x < 5) {

y = x^2;

} else {

y = x^3;

}

If else statement.

if(x < 5) {

if(x > 0) {y = x^2;}

} else {

y = x^3;

}

Nested if statement with else.

if(x < 5) {

y = x^2;

} else if ( x > 10 ) {

y = 2*x;

}

Chained if else if statement.

 

Examples

This example shows a simple if, OR, AND logical statement

clear;

a=1;

b=2;

d=3;

 

if((a==1)|(b==2)&(d==3)){

?"correct";}

else{

?"not correct";}

 

See Also

Loops, for, Operators, ==, almostequal, ?

Copyright Lumerical Inc. | Privacy | Site Map