how p(:,j) differs from p(j,:)?

I often see people using these,
how p(:,j) differs from p(j,:)?

 Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 27 Dec 2012
Edited: Azzi Abdelmalek on 27 Dec 2012
p=[1 2;3 4;5 6]
check this
p(:,2)
p(3,:)
p(:,2) means all lines, column number 2, p(3,:) means all columns, line number 3

1 Comment

if we have n points =21
I saw a code the author wrote:
p(ny,:) where p is some matrix, how can we understad it, I know the first one refers to rows and the second for columns but how can we understand it what rows is he speaking about

Sign in to comment.

More Answers (1)

Wayne King
Wayne King on 27 Dec 2012
Edited: Wayne King on 27 Dec 2012
p(:,j) takes all the rows and the j-th column of p
p(j,:) takes the j-th row and all the columns of p
So
p = [1 2; 3 4];
j = 1;
p(j,:)
p(:,j)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!