When the error comes, how to return a flag but not stop the process

5 vues (au cours des 30 derniers jours)
博文 李
博文 李 le 20 Oct 2021
Commenté : 博文 李 le 21 Oct 2021
Sometimes when I use "vpainteral" for the integral of a piecewise function, it does not work, then will report an error and stop the process. I am wondering whether MATLAB can return a flag or some numbers but not stop my process, such that I can use the my-made method replace (much more time-consuming) to solve it at that time.
Thanks in advance.
  2 commentaires
Walter Roberson
Walter Roberson le 20 Oct 2021
Does vpaintegral() itself report an error? If so, what is the error?
Or is vpaintegral() just returning an unresolved vpaintegral() expression, and the rest of your code is not expecting that?
博文 李
博文 李 le 21 Oct 2021
"double(vpaintegral(INS_INX_CAP_FUN,T_MIN,T_MAX))" will be wrong with
Error using symengine
Unable to convert expression containing remaining symbolic function calls into double array. Argument must be expression that evaluates to number.
Error in sym/double (line 800)
Xstr = mupadmex('symobj::double', S.s, 0);
The INS_INX_CAP_FUN is a piecewise function as like
piecewise(mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416) in Dom::Interval([0], 1165313976553531/35184372088832) & (2896007884017551*2^(356569039086329/17179869184000000))/816205918912235008 - 2896007884017551/816205918912235008 < 1/(((3077304917261093*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/2251799813685248 - (6011815895049549*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/281474976710656 + 996919633055797/1099511627776)^2 + ((2040108213996589*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/140737488355328 + (2976440700760609*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/562949953421312 - 3453068943317637/4398046511104)^2)^(3/4) & mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208) in Dom::Interval([0], 5588896607027279/17592186044416), (10000000*log(816205918912235008/(2896007884017551*(((3077304917261093*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/2251799813685248 - (6011815895049549*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/281474976710656 + 996919633055797/1099511627776)^2 + ((2040108213996589*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/140737488355328 + (2976440700760609*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/562949953421312 - 3453068943317637/4398046511104)^2)^(3/4)) + 1))/log(2), mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416) in Dom::Interval([0], 1165313976553531/35184372088832) & (2896007884017551*2^(356569039086329/17179869184000000))/816205918912235008 - 2896007884017551/816205918912235008 < 1/(((2040108213996589*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/140737488355328 - (2976440700760609*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/562949953421312 + 25494418663792753114220555171887/9903520314283042199192993792)^2 + ((6011815895049549*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/281474976710656 + (3077304917261093*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/2251799813685248 - 70315293125325115106280632402027/39614081257132168796771975168)^2)^(3/4) & mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208) in Dom::Interval([5588896607027279/17592186044416], 5588896607027279/8796093022208), (10000000*log(816205918912235008/(2896007884017551*(((2040108213996589*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/140737488355328 - (2976440700760609*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/562949953421312 + 25494418663792753114220555171887/9903520314283042199192993792)^2 + ((6011815895049549*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/281474976710656 + (3077304917261093*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/2251799813685248 - 70315293125325115106280632402027/39614081257132168796771975168)^2)^(3/4)) + 1))/log(2), mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416) in Dom::Interval([1165313976553531/35184372088832], 1165313976553531/17592186044416) & mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208) in Dom::Interval([0], 5588896607027279/17592186044416) & (2896007884017551*2^(356569039086329/17179869184000000))/816205918912235008 - 2896007884017551/816205918912235008 < 1/(((6011815895049549*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/281474976710656 + (3077304917261093*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/2251799813685248 - 5031852398038993589438635124927/9903520314283042199192993792)^2 + ((2976440700760609*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/562949953421312 - (2040108213996589*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/140737488355328 + 866923229301288165552489782879/4951760157141521099596496896)^2)^(3/4), (10000000*log(816205918912235008/(2896007884017551*(((6011815895049549*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/281474976710656 + (3077304917261093*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/2251799813685248 - 5031852398038993589438635124927/9903520314283042199192993792)^2 + ((2976440700760609*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/562949953421312 - (2040108213996589*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/140737488355328 + 866923229301288165552489782879/4951760157141521099596496896)^2)^(3/4)) + 1))/log(2), mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416) in Dom::Interval([1165313976553531/35184372088832], 1165313976553531/17592186044416) & (2896007884017551*2^(356569039086329/17179869184000000))/816205918912235008 - 2896007884017551/816205918912235008 < 1/(((2040108213996589*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/140737488355328 + (2976440700760609*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/562949953421312 - 35003885125600300628797939856621/9903520314283042199192993792)^2 + ((6011815895049549*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/281474976710656 - (3077304917261093*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/2251799813685248 + 14270068429581788942475215379823/39614081257132168796771975168)^2)^(3/4) & mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208) in Dom::Interval([5588896607027279/17592186044416], 5588896607027279/8796093022208), (10000000*log(816205918912235008/(2896007884017551*(((2040108213996589*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/140737488355328 + (2976440700760609*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/562949953421312 - 35003885125600300628797939856621/9903520314283042199192993792)^2 + ((6011815895049549*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/281474976710656 - (3077304917261093*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/2251799813685248 + 14270068429581788942475215379823/39614081257132168796771975168)^2)^(3/4)) + 1))/log(2), mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416) in Dom::Interval([0], 1165313976553531/35184372088832) & 1/(((3077304917261093*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/2251799813685248 - (6011815895049549*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/281474976710656 + 996919633055797/1099511627776)^2 + ((2040108213996589*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/140737488355328 + (2976440700760609*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/562949953421312 - 3453068943317637/4398046511104)^2)^(3/4) < (2896007884017551*2^(356569039086329/17179869184000000))/816205918912235008 - 2896007884017551/816205918912235008 & mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208) in Dom::Interval([0], 5588896607027279/17592186044416) | mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416) in Dom::Interval([1165313976553531/35184372088832], 1165313976553531/17592186044416) & mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208) in Dom::Interval([0], 5588896607027279/17592186044416) & 1/(((6011815895049549*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/281474976710656 + (3077304917261093*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/2251799813685248 - 5031852398038993589438635124927/9903520314283042199192993792)^2 + ((2976440700760609*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/562949953421312 - (2040108213996589*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/140737488355328 + 866923229301288165552489782879/4951760157141521099596496896)^2)^(3/4) < (2896007884017551*2^(356569039086329/17179869184000000))/816205918912235008 - 2896007884017551/816205918912235008 | mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416) in Dom::Interval([1165313976553531/35184372088832], 1165313976553531/17592186044416) & 1/(((2040108213996589*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/140737488355328 + (2976440700760609*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/562949953421312 - 35003885125600300628797939856621/9903520314283042199192993792)^2 + ((6011815895049549*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/281474976710656 - (3077304917261093*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/2251799813685248 + 14270068429581788942475215379823/39614081257132168796771975168)^2)^(3/4) < (2896007884017551*2^(356569039086329/17179869184000000))/816205918912235008 - 2896007884017551/816205918912235008 & mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208) in Dom::Interval([5588896607027279/17592186044416], 5588896607027279/8796093022208) | mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416) in Dom::Interval([0], 1165313976553531/35184372088832) & 1/(((2040108213996589*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/140737488355328 - (2976440700760609*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/562949953421312 + 25494418663792753114220555171887/9903520314283042199192993792)^2 + ((6011815895049549*mod(t + 3262727792551503/140737488355328, 1165313976553531/17592186044416))/281474976710656 + (3077304917261093*mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208))/2251799813685248 - 70315293125325115106280632402027/39614081257132168796771975168)^2)^(3/4) < (2896007884017551*2^(356569039086329/17179869184000000))/816205918912235008 - 2896007884017551/816205918912235008 & mod(t + 5613126887686237/35184372088832, 5588896607027279/8796093022208) in Dom::Interval([5588896607027279/17592186044416], 5588896607027279/8796093022208), 0)
It's a lillte bit long, simply, it is:
"INS_INX_CAP_FUN = piecewise((CAP_FUN(t)>INS_CAP), CAP_FUN(t), (CAP_FUN(t)<INS_CAP), 0);"
where CAP_FUN(t) is another piecewise function, and INS_CAP is a constant.
By the way, when INS_CAP is set some other numbers around the number error occures, the process is work, that is
"double(vpaintegral(INS_INX_CAP_FUN,T_MIN,T_MAX))" is work.

Connectez-vous pour commenter.

Réponse acceptée

Bruno Luong
Bruno Luong le 20 Oct 2021
You might learn about

Plus de réponses (0)

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by