Take row from a vector based on the value of another vector

1 Ansicht (letzte 30 Tage)
Zair Ahmedi
Zair Ahmedi am 4 Jul. 2018
Kommentiert: Stephen23 am 4 Jul. 2018
For example, I have this column vector:
A =
0
5.1205
5.6338
0
2.9639
5.6774
0
2.6281
0.7772
2.5641
I want to remove other rows and take only rows where the index is from a vector
B =
2
3
5
6
8
9
10
So, it will become
C =
5.1205
5.6338
2.9639
5.6774
2.6281
0.7772
2.5641
  1 Kommentar
Stephen23
Stephen23 am 4 Jul. 2018
Very basic MATLAB concepts, such as how to use indexing, are explained in the introductory tutorials. These are highly recommended for all beginners:

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Robert U
Robert U am 4 Jul. 2018
Hi Jerry,
Matlab documentation is your friend:
C = A(B)
Kind regards,
Robert

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by