MATLAB Answers

How can I impose restrictions on a function @

10 views (last 30 days)
ektor on 5 Jun 2020
Commented: Mohammad Sami on 5 Jun 2020
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?
Mohammad Sami
Mohammad Sami on 5 Jun 2020
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');

Sign in to comment.

Answers (0)


Community Treasure Hunt

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

Start Hunting!

Translated by