MATLAB: ‘solve’: simple functions throw geteqns lne 404 error

geteqns lne 404MATLABsolve

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.

Best 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])