Tips and tricks: Difference between revisions

2 bytes removed ,  24 May 2012
m
→‎Vectorizing Tricks: Use of brackets [] is unnecessary
m (→‎Vectorizing Tricks: Use of brackets [] is unnecessary)
Line 123: Line 123:
     for i=1:n, x(i) = i; end
     for i=1:n, x(i) = i; end


     x = [1:n];
     x = 1:n;


This works for expressions on the index by wrapping the index in an expression:
This works for expressions on the index by wrapping the index in an expression: