I have a problem, I am working with numerical approximations.
Now I have $-1=x_0<x_1 <...<x_n=1$ with $x_i=x_{i-1}+h$ and $h=2/n$. Now given a function $f$, I want to find $f(x_i)$ for $i=1:n-1$ and store it in a column matrix $F$.
How will I code it in matlab? Here is my code but it does not working. Any help is appreciated.
function F = matrix(f , n)
h=2/n;
for i=1:n-1;
x(0)=-1;
x(n)=1
x(i)=h+x(i-1)
end
endfunction
The function header specifies the output as F, but you don't assign any value to F in your code. Nor do you ever use f. All you are doing is producing the array x (and that in an inefficient way, but that's beside the point).