How can I impose restrictions on a function @

조회 수: 6 (최근 30일)
ektor
ektor 2020년 6월 5일
댓글: Mohammad Sami 2020년 6월 5일
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
James Tursa
James Tursa 2020년 6월 5일
Just a simple if-test up front to throw an error if the desired condition is not met.
Mohammad Sami
Mohammad Sami 2020년 6월 5일
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');

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by