« Earlier2 items total Later »

Extract last k rows from a matrix

>> k = 2;
>> a = rand(5)

a =

    0.1934    0.6979    0.4966    0.6602    0.7271
    0.6822    0.3784    0.8998    0.3420    0.3093
    0.3028    0.8600    0.8216    0.2897    0.8385
    0.5417    0.8537    0.6449    0.3412    0.5681
    0.1509    0.5936    0.8180    0.5341    0.3704

>> a(end-k+1:end,:)

ans =

    0.5417    0.8537    0.6449    0.3412    0.5681
    0.1509    0.5936    0.8180    0.5341    0.3704

Swap rows of a matrix

M([1,5],:) = M([5,1],:)

interchanges rows 1 and 5 of M.

More generally, if V has m components and W has n components, then M(V,W) is the m-by-n matrix formed from the elements of M whose subscripts are the elements of V and W.

« Earlier2 items total Later »




Sponsored by

Sole Central

Your one stop shop for Birkenstock and Crocs shoes and sandles.