필터 지우기
필터 지우기

Matlab function with inf in end points

조회 수: 1 (최근 30일)
george veropoulos
george veropoulos 2022년 9월 4일
댓글: george veropoulos 2022년 9월 7일
hi
I have a function define in an range [ a, b ] the function is ιnf at end point F(a)=inf F(b)=inf
there a method to eliminate this singular point?
thank
George
  댓글 수: 2
Matt J
Matt J 2022년 9월 4일
편집: Matt J 2022년 9월 4일
You can rewrite F to give whatever alternative value you wish at a and b, e.g,
tand(89)
ans = 57.2900
tand(90)
ans = Inf
F(89)
ans = 57.2900
F(90)
ans = 0
function f=F(x)
f=tand(x);
if isinf(f), f=0; end
end
but whether that will solve your ultimate problem, we've no way of knowing, without more context.
george veropoulos
george veropoulos 2022년 9월 4일
이동: Matt J 2022년 9월 4일
Thank tou I. Move the and point a liitle. I add a small number an i substrat a small number. I want cokpare with a. Monte catlo simulation

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

채택된 답변

Walter Roberson
Walter Roberson 2022년 9월 4일
Possibly
In some cases, inf shows up due to loss of precision. For example, if you had A = 1e100, B = 1e10 then A-B is going to evaluate in double precision as being the same as A, in a context where you end up with an infinity as a consequence. These kind of situations can be reduced by using the Symbolic Toolbox.
In some cases, you are working with expressions that mathematically evaluate to something but when evaluated naïvely in floating point numbers, evaluate to inf or nan. Such situations can be reduced by using the Symbolic Toolbox and taking limit() of evaluating an expression at a particular value, instead of just evaluating the expression at the value directly.
In some cases, when you are operating in floating point, temporary expressions can overflow to infinity as far as floating point is concerned, whereas they might mathematically be well defined. For example, log(exp(x)+1) when x > roughly 709.7827. Such situations can be reduced by using the Symbolic Toolbox.
In some cases, you can get around problems by rewriting the order of operations, such as 0.1 + 0.2 - 0.3 being different than 0.1 -0.3 + 0.2 .
In some cases, you can get around problems by doing a log transformation, such as log(y) = log(x1) + log(x2) + log(x3) - log(x4) instead of y = x1 * x2 * x3 / x4
  댓글 수: 3
Walter Roberson
Walter Roberson 2022년 9월 5일
In that case, NO, you have unremovable discontinuities, and your mathematical choices at those points are +/- inf or nan .
george veropoulos
george veropoulos 2022년 9월 7일
thank !

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by