I am trying to write a script to implemet a function such as this one
function[output1, output2, ....] = my_function(constant, coefficient_vector, xValue)
where a0=contant, a1=coefficient_vector(1), a2=coefficient_vector(2), ... and so on.
coefficient_vector may vary in size and content i.e it could be [ 1 ] or it could be [ 1 2 1 3 1 ] or [ 0 7 5 0 6 4 .......] positive integers only, without any size restriction. Also, constant could be any integer.
In case of [ 1 ], script should print out f(x) = cos(x). In case of [ 1 1 1 1 1 ], print out f(x) = cos(x) + 2*cos(2*x) + cos(3*x) + 3*cos(4*x) + cos(5*x) and so on...
Then calculate the value of f(xValue)
I have already did it as using symbolic function but the task is to do without symbolics
f(x) = coeffVector(i) * cos(i*x) + f(x);
f(x) = f(x) + constant;
So, how can I do this?