I am new to octave and still learning what I can and cannot do with it. I am asked to write a following function ('trigmin'):
[a, b, c, info]=tigmin(x,y)
Where x, y are vectors of the same length (let's say n) and the function output is the triple [a, b, c] where the triple minimizes the following expression $$\sum_{i=1}^n|a+b \cos(x_i)+c\sin(x_i)-y_i|^2$$
info = reports if the problem has non-unique solutions or if the vector sizes don't match.
The soln part is the one I am concerned with. Using symbols I would say a,b,c are symbols then build A matrix [ones(n),\cos{x},\sin{x},y]
and multiply [a;b;c;-1][ones(n),\cos(x),\sin(x),y]
to get a vector norm which I am trying to minmize. However in the class we haven't used symbolic package so I assume it is doable without using symbols.
Am I doing it right using symbols?
Is it possible not to use symbols? If so, then how?
The problem is simple and no loops are required
Any hints would be much appreciated.