How to define if variable with one unknown parameter

Hi,
Working with the JONSWAP spectrum, with an unknown frequency f and a known frequency fp
Sigma value is depending on the relation between f and fp.
If f is smaller or equal to fp, then sigma = 0.07
If f is larger than fp, then sigma = 0.09
Could someone explain how to perform this is in Matlab?

 Respuesta aceptada

Star Strider
Star Strider el 7 de Mzo. de 2015
Editada: Star Strider el 7 de Mzo. de 2015
The easiest way:
sigmafun = @(f,fp) [(f <= fp)*0.07 + (f > fp)*0.09];
sigma1 = sigmafun(1,2) % Test Calls
sigma2 = sigmafun(2,1)
sigma3 = sigmafun(3,3)

2 comentarios

Thank you @Star Strider.
My pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Preguntada:

el 7 de Mzo. de 2015

Comentada:

el 7 de Mzo. de 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by