Error: "Attempted to access stream(3); index out of bounds because numel(stream)=2."

Hi all,
I am trying to write a minimization function. I have the function below and am then using it with fminunc to minimize. However, I keep getting the error above. Any advice?
-Kyle
function E2 = hw07p7func(stream)
s1 = stream(1) ; s2 = stream(2) ; s3 = stream(3) ; s4 = stream(4) ;
r1 = s1-.996*s3-.196*s4 ; r2 = .99*s2-.8*s4 ; r3 =.01*s2-.04*s3-.04*s4 ;
E2 = (r1.^2 + r2.^2 +r3^2)

Answers (0)

Tags

Asked:

on 31 Mar 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!