*This list is being expanded
- The period . operator.
You put the . in front of an operator like ^ or * to get “element by element” operation behavior. Its best explained by example.
Say you have a row matrix called ‘x’ that has 10000 values in it.
You want a plot of y = x2, so you need to create another row vector to save values of y to put those values in.
Instead of writing a loop like:
for( i = 1:length(x) )
y(i) = x(i)^2;
endJust use the special . notation and write:
x = -3:0.01:3;
y = x.^(2);Here, .^ means to raise every element of x to the power of 2, not to try to raise the ENTIRE matrix to the power 2 (which clearly generates an error).