How can i get specific rows of a matrix without using loops?

6 views (last 30 days)
My question is, how can I get matrix c in an efficient way?(no loops)
c represents the rows of a, given b.
a=[10 14 12 15
12 11 12 18
11 14 28 15
18 11 15 18
20 11 45 85]
b=[1
4
2]
c=[10 14 12 15
18 11 15 18
12 12 12 18]
Thank you in advance

Accepted Answer

Bob Thompson
Bob Thompson on 8 Feb 2018
c = a(b,:);

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!