filtering values of one matrix according to another

2 ビュー (過去 30 日間)
Sara
Sara 2012 年 10 月 10 日
Hi, I want to filter out rows of one matrix (V) according to values in another (F) and store them in another matrix, V1. F corresponds to some values in the 3rd column of V. The values in F are non-consecutive so a simple loop wouldn't work. Yet filtering using logical indexing (which I normally use) won't work either since F is not a scalar. I'm not a programmer and not a frequent matlab user so it's difficult for me to grasp what's going wrong. I've pasted some of the versions that haven't worked below:
%1 -- didn't work because F is neither a scalar nor the same size of V
F = [4;5;6;9;10;11];
V1 = V((V(:,3) == F ):);
%2 -- this gave a syntax error
start(F(1,1);
end(F(6,1);
V1 = V((V(:,3) >= start <= end ):);
Sounds really stupid but I don't know how to do this?
Sorry!
  1 件のコメント
Thomas
Thomas 2012 年 10 月 10 日
give an expample of your two inputs and the output you need.. would be easier for us to understand the question..

サインインしてコメントする。

採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 10 月 10 日
V1 = V(ismember(V(:,3),F),:);

その他の回答 (1 件)

Sara
Sara 2012 年 10 月 10 日
Brilliant! Thanks

カテゴリ

Help Center および File ExchangeMatched Filter and Ambiguity Function についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by