Skip navigation

*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;

    Just 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).

    matlab docs ref

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: