How can I impose restrictions on a function @

Dear all
I have a compicated function
logPDF=@(x) set_up(x, a,y);
under the restriction x+a<0.999.
How can I impose this restriction on the above function? Do I need to set up another function? Can I impose the restrctions inside the set_up function?

5 comentarios

ektor
ektor el 5 de Jun. de 2020
any help?
Mohammad Sami
Mohammad Sami el 5 de Jun. de 2020
If the set_up function has this restriction, you need to edit the set_up function.
ektor
ektor el 5 de Jun. de 2020
OK. So inside the set_up function I construct another function?
James Tursa
James Tursa el 5 de Jun. de 2020
Just a simple if-test up front to throw an error if the desired condition is not met.
You can use assert function to check the condition is met, otherwise it will throw an error.
assert((x+a)<0.999,'Error message you want to display / throw');

Iniciar sesión para comentar.

Respuestas (0)

Preguntada:

el 5 de Jun. de 2020

Comentada:

el 5 de Jun. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by