I want to solve a trigonometric equation numerically for $a$ via Matlab
$$\sin(k+a)=x\cos(k)$$
where $a$ is an argument of a complex number. Both $a$ and $k$ vary between $0\leq k\leq\pi$.
I want to have solution sol[x,k], so that for each $x$ and $k$ I get (either zero, one, two or more) solutions $a$. Then to plot them, or visualize via a Table. This is done straightforwardly via Mathematica; however, I want to achieve it via Matlab, if easily possible. The code that I wrote upto now is
clear all
k=[0:0.1:pi]
x=[0:0.1:pi]
f=sin(k+a)-x*cos(k);
for i=1:3
vpasolve(f,a,'random',true)
end
However, it doesn't get me any closer. Thanks.
You may want to try something like this:
EDIT: The following code reflects most of the discussion in the comments. It shows how to compute all solutions symbolically and stores them in a cell array:
The entry of the array that are not assigned in the loop contain empty matrices, which are detected in further processing by calling
isempty.