Jessada Thutkawkorapin
Jessada Thutkawkorapin

Reputation: 1346

How to apply indices I got from one row to other rows in matlab?

Let say if I have this data

my_data = [ 10 20 30 40; 0.1 0.7 0.4 0.3; 6 1 2 3; 2 5 4 2];
my_index = logical(my_data(4,:)==2);

What is the simplest way to use 'my_index' to give this output

10.0000   40.0000
0.1000    0.3000
6.0000    3.0000
2.0000    2.0000

Upvotes: 1

Views: 43

Answers (1)

High Performance Mark
High Performance Mark

Reputation: 78364

my_data(:,my_index)

but I'm suspicious that this is so simple that it doesn't satisfy your (background) requirements ...

Upvotes: 1

Related Questions