フィルターのクリア

How to compare the values ​​of three matrices are equal?

3 ビュー (過去 30 日間)
Jadiel Silva
Jadiel Silva 2013 年 7 月 7 日
Hi
I need help with comparison matrices. I'm new to MatLab. Please help me.
I have three matrices R, S and T (size 95956x1) and I need to compare all elements them and see which elements are equal, then the same values we multiply by a fourth matrix.
In a Matlab file I read the coordinates and separate them into three matrices, thus obtaining matrices R, S and T saved in "data.mat". Then I read in another file "data.mat" and opened a For loop
for t=1:1:length(CoordinateIndex)
index = R == S ;
ts=ts+1;
end
Now I do not know if this is correct and how I will multiply to only those values which are equal to a fourth matrix. Please could you help me? I am very grateful
Jadiel
  2 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 7 月 7 日
編集済み: Azzi Abdelmalek 2013 年 7 月 7 日
can you explain: then the same values we multiply by a fourth matrix. And you did not precise what are you going to multiply by the fourth matrix
per isakson
per isakson 2013 年 7 月 7 日

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

採用された回答

per isakson
per isakson 2013 年 7 月 7 日
I don't exactly understand what you want to do. However, here is an extra example to the documentation on locigal indexing.
Create some data. It's short column vectors to make them easy to inspect.
N = 12;
R = randi( [1,3], [N,1] );
S = randi( [1,3], [N,1] );
T = randi( [1,3], [N,1] );
f = randi( [1,3], [N,1] );
Create a logical index, which is true when R(i)==S(i), else is false
is_RS = (R==S);
Multiply T(i) by f(i) where R(i)==S(i)
T(is_RS) = f(is_RS) .* T(is_RS);
  1 件のコメント
Image Analyst
Image Analyst 2013 年 7 月 7 日
Exactly how I'd do it. Works for integers only. For floating point values, see the FAQ: http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F for solution.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by