MATLAB: How to solve an equation, with infinite solutions, to find only n number of solutions

infinite solutionsMATLABmultiple solutionssolve

I am trying to find a finite number of solutions to an equation with infinite solutions, I am not really sure how to approach this problem.
cos(x)*cosh(x) = 1
In the equation above, there are infinite number of soluions for x. How should I write the code to get the first 5 solutions?

Best Answer

fun = @(x)cos(x)*cosh(x)-1;
Interval = zeros(4,2);
Interval(1,:) = [3/2*pi, 3/2*pi+0.5];
Interval(2,:) = [5/2*pi, 5/2*pi-0.5];
Interval(3,:) = [7/2*pi, 7/2*pi+0.5];
Interval(4,:) = [9/2*pi, 9/2*pi-0.5];
sol = zeros(5,1);
for i = 1:4
sol(i+1) = fzero(fun,Interval(i,:))
end