Invalid index error simulating bipolar NRZ on SCILAB

34 Views Asked by At

I'm trying to simulate a bipolar NRZ of [1 1 0 0 1 0 0 0 1 1] on SCILAB. But I keep getting error of "invalid index". Need help...

This is the error that I get on SCILAB.

invalid index

This is my source code. source code

1

There are 1 best solutions below

0
Marc On

It looks like a simple indexing error.

Remember that, in Scilab, arrays are indexed starting from 1 (not 0 like Python or other languages)

In your code, you are checking a elseif condition involving x(i - 1) and your for loop loops through 1:L, so, at the first comparison iteration, x(0) will be tested, which is undefined/invalid.