필터 지우기
필터 지우기

How to get rid of floating-point constants

조회 수: 23 (최근 30일)
ssmith
ssmith 2021년 11월 16일
댓글: James Tursa 2021년 11월 16일
I am trying to evaluate this expression but I get an error saying I have a floating-point constant. If I add another parenthases to separate the 7 and e, then I get an error saying I am missing more parenthases when I know I am not. Any one have advice on how to fix this equation?
A = 25 - (100 - 7exp(5+cos(pi/3)))

답변 (1개)

Dave B
Dave B 2021년 11월 16일
The error you describe isn't what I'd expect, but you're certainly missing a *. Unless exp isn't the matlab function exp and is some e.g. symbolic variable?
A = 25 - (100 - 7*exp(5+cos(pi/3)))
A = 1.6378e+03
  댓글 수: 2
ssmith
ssmith 2021년 11월 16일
@Dave B Do you know what the error means "Invalid Floating-point constant"
James Tursa
James Tursa 2021년 11월 16일
@ssmith The parser sees the characters 7e... and thinks you are trying to enter a floating point number like 7e2, but when it gets to the x character it can't read the exponent so it throws the error. Basically you have invalid syntax which was misleading the parser.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by