Tell me, what is fx?
fx is NOT a function. It is a scalar, vector, or array. Whatever x was, fx is the same thing. If it NOT a function that you can evaluate at some point. So then, when you write
I_simp_seg = 1/6*(fx(0) + 4*fx(mid) + fx(4));
what does MATLAB do? It KNOWs that fx is a variable. It tries to index the variable at position 0. What did it tell you?
Array indices must be positive integers or logical values.
You need to learn how to write a FUNCTION that can be passed arguments. You MIGHT try a function handle.
A simple example for your problem here would be
0 Comments
Sign in to comment.