Solve Function for Given Range of Inputs

syms x
x = sym('x')
x = -4:4
eqn = exp(-x.^2) == f(x)
S = solve(eqn,x)

I keep getting an error message when trying to folve the function f(x) for values of x -4 through 4. How would i define f(x) to get rid of the error message?

댓글 수: 2

AndresVar
AndresVar 2022년 2월 27일
here is an example to restrict the solution for x
What is f(x) in your case?
Torsten
Torsten 2022년 2월 27일
How would i define f(x) to get rid of the error message?
Depends on which equation you are trying to solve.
What you write at the moment does not make sense since you already fix x as x=-4:4.
So exp(-x.^2)==f(x) is either true or false depending on f, but you can't solve for x.

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

답변 (1개)

Walter Roberson
Walter Roberson 2022년 2월 27일
syms x real
f(x) = sin(x)
f(x) = 
eqn = exp(-x.^2) == f(x)
eqn = 
Sn = vpasolve(eqn, x, [-4 4])
Sn = 

카테고리

도움말 센터File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

태그

질문:

2022년 2월 26일

답변:

2022년 2월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by