I am trying to solve this equation: $e^x=x^e+e$ in MATLAB, but I continually get an error. I do not know where to go from here. Any help is appreciated This is what I have:

a = x^exp(1) + exp(1) == exp(x);
syms x
b = solve(a,x);

  • 2
    $\begingroup$ Initialise x before using it. $\endgroup$ – David Apr 27 '16 at 22:49

You need to tell Matlab that $x$ is symbolic before you use it. Swap your first and second lines.

enter image description here

| cite | improve this answer | |
  • $\begingroup$ I did that and recieved this error: Error using sym/subsindex (line 737) Invalid indexing or function definition. When defining a function, ensure that the arguments are symbolic variables and the body of the function is a SYM expression. When indexing, the input must be numeric, logical, or ':'. $\endgroup$ – Nate Apr 27 '16 at 22:58
  • $\begingroup$ @Nate included an image to demonstrate with an approximate check. $\endgroup$ – Mike Miller Apr 27 '16 at 23:01
  • 1
    $\begingroup$ @Nate Is it possible you've made a mistake elsewhere in your code? I can't see why you should have any problem. $\endgroup$ – Mike Miller Apr 27 '16 at 23:07
  • 2
    $\begingroup$ Have you defined a variable called exp? Clear the workspace and run your code again. $\endgroup$ – David Apr 28 '16 at 1:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.