I am new to matlab. Anyone know how does the colon operator works in the 2 equations?
a= [ 0.003:1/1024:0.5 ]
b= [ 1/512:1/512:i ]
Best Answer
Thecolon operator creates vectors. In your illustration, it creates‘a’ starting at0.003, incrementing by1/1024, and ending at0.5. The‘b’ vector starts at1/512, increments by1/512, and ends at whatever variable‘i’ is. (Note: using‘i’ or‘j’ as variables, including as loop counters, is not good programming practice. MATLAB uses them for its imaginary operators, and using them otherwise causes confusion.)
The easiest way to solve that is to use thelinspace function to define‘x’ and‘y’. It allows you to specify thelength of the vector, varying the increment to accomodate that. (Thecolon operator fixes the increment and lets the length vary.)
Best Answer