MATLAB: Unbalanced or Unexpected parenthesis or bracket

bracketparanthesisunbalanced parenthesisunexpected parenthesis

Hi, I have the following code, in which there is a matrix b, I want to plot the even index values against odd index values once I have done a conversion to 8-bit signed equivalent:
MATLAB gives me an unbalanced or unexpected parentheses or bracket error and I fail to understand why, as I don't see any error in my code, please help, below is my code:
i=1;
for i=1:1000
if i%2~=0
if b[i]>127 %b is a two dimensional matrix of dimensions 1000 * 1
b[i]=b[i]-256;
x[i]=b[i];
else
x[i]=b[i];
end
else
if b[i]>127
b[i]=b[i]-256;
y[i]=b[i];
else
y[i]=b[i];
end
end
i=i+1;
end
i=1
for i=1:10000
plot (x[i],y[i]);
end
I get the error at line 5, i.e.
b[i]=b[i]-256;

Best Answer

MATLAB uses round parentheses to indicate array elements, not square brackets. You probably ported that from another language and forgot to convert the brackets.