'solve': simple functions throw geteqns lne 404 error

Hello
I am using MATLAB online and the following code throws an error
The same code with ==0 instead of ==1 works fine.
What is the problem?
D
clear all;
clc;
syms x;
[solx, param, cond] = solve(x*cot(x)==1, x, 'ReturnConditions', true);
> In sym/solve (line 317)
In solutionsPS67 (line 4)
Error using sym/solve>getEqns (line 404)
Input argument contains an empty equation or variable.

4 Comments

syms x;
[solx, param, cond] = solve(x*cot(x)==1, x, 'ReturnConditions', true);
works for me online, just saying that there is no explicit solution.
Thanks for looking into it,
There are actually solutions for ==1, ==2 etc.. just fplot(x*cot(x), [0 2*pi])
Any value at the right of == seems to throw an error, irrespective of the value
D
For me it throws:
Warning: Unable to find explicit solution. For options, see help.
> In sym/solve (line 317)
In solutionsPS67 (line 4)
Error using sym/solve>getEqns (line 404)
Input argument contains an empty equation or variable.
It is actually the following code that makes it throw the error:
syms x;
[solx, param, cond] = solve(x*cot(x)==0.01, x, 'ReturnConditions', true);
assume(cond);
solk = solve(0<solx, solx<2*pi, param);
If I comment the last two lines I am left only with the Warning, it seems the equation
does not solve as expected, something is missing?
Thanks a lot
D

Sign in to comment.

 Accepted Answer

solve() is designed to return indefinitely precise solutions whenever it can figure out how.
If it cannot figure out how to calculate a formula for the solution, then if the number of equations matches the number of variables and there are no inequalities, solve() will attempt to find one numeric solution, unless returnconditions was asked for, in which case it will return empty.
With your solution returning empty, (0<solx, solx<2*pi, param) is empty, so you are asking to solve an empty system, which is where the error is coming from.
You should use vpasolve() with a range argument,
vpasolve(x*cot(x)==0.01, x, [0, 2*pi])

1 Comment

Many Thanks
vpasolve is the right function for me, understood

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!