# Knowledge Base

 Navigation: Scripting Language > Functions max We've made some changes. Use 'Ctrl-F5' to clear your browser cache.

Returns the maximum value in a matrix. For complex numbers, only the real part is considered.

 Supported Product: FDTD, MODE, DEVICE, INTERCONNECT

 Syntax Description out = max(x); The maximum value in matrix x.

Example

Simple example showing how to find the maximum value of a vector.

?x=linspace(0,3,4);

result:

?max(x);

result:

3

Simple example showing how complex numbers are treated.

?x = 3 + 4i;

?max(x);

?max(abs(x));

result:

3+4i

result:

result:

Find the maximum field intensity at each frequency point.

# plot the maximum value of an 3D E-field by frequency

E2  = getelectric("3D field monitor");

f   = getdata("3D field monitor","f");

E_dim = size(E2);            # dimensions of matrix E

data = matrix(E_dim(4));        # make a matrix of size E_dim(4) ie. number of freq pts

for (i=1:E_dim(4)) {

maxVal = max( pinch(E2,4,i) );        # pick out data at a certain freq

data(i)=maxVal;

}

plot(f,data,"Frequency (Hz)","Maximum E intensity");