MATLAB: Error: Unbalanced or unexpected parantheses

error

Can someone please explain to me the problem with my function. All the variables have already been assigned.
function [u,w] = velocity(H,sigma(n),k,h(n),z,x)
n = 1:length(h)
h = [1 2 3 4]

Best Answer

You cannot use indexing in the arguments listed in the function definition. Try instead:
function [u,w] = velocity(H,sigma,k,h,z,x)
...
You can then call the function, passing various elements of arrays as arguments:
[u,w] = velocity(H,sigma(n),k,h(n),z,x);
Related Question