필터 지우기
필터 지우기

I raise a decimal number to a decimal power and it gives my infinity! How may I avoid that?

조회 수: 9 (최근 30일)
Hello All,
In part of my code, I am raising a decimal number to a decimal (negative) power and MATLAB gives me infinity! Clearly this is not true, and I was wondering how I may get around that. Here are the numbers when I print those numbers using a long format: base is 0.692557726286390 and exponent is -2.113743738000000. Of course, when I use these exact numbers in MATLAB and do (0.692557726286390 ^ -2.113743738000000), MATLAB does not generate infinity, but in my code it does. I believe the difference comes from the fact that those numbers that I reported are just representations of the actual numbers. But anyways I believe that raising a decimal number to another decimal number should not generate infinity. I appreciate your thoughts on how I may get around this problem.
Many Thanks,
Hamid
  댓글 수: 3
Hamid Firooz
Hamid Firooz 2020년 7월 2일
Thanks for your comment. I was working on creating a simple version of my code to post here, and I found a typo creating the issue. Sorry for bothering you.
Rik
Rik 2020년 7월 3일
No problem. That is the usefulness of writing a MWE.

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

답변 (1개)

Vashist Hegde
Vashist Hegde 2020년 7월 3일
Try using a "." before you use the power (^) operator whenever you operate on individual values rather than matrices.
  댓글 수: 1
Hamid Firooz
Hamid Firooz 2020년 7월 3일
I guess you mean the opposite, no? I mean we need to use "." when we use the power operator for matrices. Anyways in my case I am using the power operator for scalars rather than matrices.

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

카테고리

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