Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

selecting every nth element from a vector matrix

1,044 views
Skip to first unread message

Akeem Wale

unread,
Mar 5, 2012, 11:00:13 PM3/5/12
to
Dear users


Can anyone guide me on how to select every nth element from a vector matrix using MATLAB codes?

Nasser M. Abbasi

unread,
Mar 5, 2012, 11:34:02 PM3/5/12
to
this selects every second. Change as needed:

EDU>> A=[1 2 3 4 5 6 7 8 9 10];
N=2;
B=A(1:N:length(A))

1 3 5 7 9

Akeem Wale

unread,
Mar 6, 2012, 2:41:12 AM3/6/12
to
"Akeem Wale" wrote in message <jj424d$52m$1...@newscl01ah.mathworks.com>...

ImageAnalyst

unread,
Mar 6, 2012, 10:18:14 AM3/6/12
to
On Mar 5, 11:00 pm, "Akeem Wale" <abu...@gmail.com> wrote:
> Dear users
>
> Can anyone guide me on how to select every nth element from a vector matrix  using MATLAB codes?

-------------------------------------------------------------------------------------------------------------
Akeem Wale:
A small adaptation from my answer to your similar 2D array question
gives this:

submatrix = fullmatrix(startingIndex : n : end);

"end" is a keyword - it means length(fullMatrix) for whatever matrix
you're indexing. In other words, it changes its value depending on
what matrix you're working on.

ImageAnalyst
0 new messages