Clear Filters
Clear Filters

Array indices must be positive integers or logical values

1 view (last 30 days)
I'm trying to do the Bairstow method but the fuctions to get delta r and delta s mark me as an error
coeff= length(fx);
r=r0;
s=s0;
ErrR=100;
ErrS=100;
while ErrR>tol || ErrS>tol
fx=fx(coeff:-1:1);
b(coeff)= fx(coeff)
b(coeff-1)= fx(coeff-1)+r*b(coeff);
for rs=(coeff-2:-1:1)
b(rs)= fx(rs)+r*b(rs+1)+s*b(rs+2);
end
c(coeff)= b(coeff);
c(coeff-1)= b(coeff-1)+r*c(coeff);
for rs=(coeff-2:-1:2)
c(rs)= b(rs)+r*c(rs+1)+s*c(rs+2);
end
deltaR= (b(0)*c(3)-b(1)*c(2))/((c(2))^2-c(1)*c(3))
deltaS= (b(1)*c(1)-b(0)*c(2))/((c(2))^2-c(1)*c(3))
r= deltaR+r;
s= deltaS+s;

Answers (1)

Jim Riggs
Jim Riggs on 9 Nov 2019
Edited: Jim Riggs on 9 Nov 2019
Matlab does not allow an index value of zero.
deltaR = (b(0) ...
similar in deltaS.

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!