Solve Function for Given Range of Inputs

10 Ansichten (letzte 30 Tage)
Braeden Elbers
Braeden Elbers am 26 Feb. 2022
Beantwortet: Walter Roberson am 27 Feb. 2022

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 Kommentare
AndresVar
AndresVar am 27 Feb. 2022
here is an example to restrict the solution for x
What is f(x) in your case?
Torsten
Torsten am 27 Feb. 2022
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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

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

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by