MATLAB: Ha(w) = 1./ ( ( (s./wo)+1).*( (s./wo).^2 + ((2*cos((si1)*s))./wo ) + 1 ).*( (s./wo).^2 + ( (2*cos((si1)*s))./wo ) + 1 ) ); Subscript indices must either be real positive integers or logicals.

subscript indices must either be real positive integers or logicals.

Why do I get the following error message for this equation

Best Answer

Define all the other relevant variables such as ‘s’ and ‘wo’, then try this:
Ha = @(w) 1./ ( ( (s./wo)+1).*( (s./wo).^2 + ((2*cos((si1)*s))./wo ) + 1 ).*( (s./wo).^2 + ( (2*cos((si1)*s))./wo ) + 1 ) );
w=0:1:2000;
Haw = Ha(w);
You need to define your function as an anonymous function.