How to compare column A and B based on the column C condition?
    1 回表示 (過去 30 日間)
  
       古いコメントを表示
    
Hello, I am a beginner at Matlab.
If I want to compare columnes A and B when column C is satisfied with the condition.
for example, in the following matrix,
in case of A(:, 3) == 1,
comparing A(:, 1) to A(:,2) is my goal. How shoud I do?
A = [1 7 0; 4 2 1;8 2 1; 2 4 1; 9 4 0]
0 件のコメント
採用された回答
  Star Strider
      
      
 2018 年 6 月 11 日
        Try this:
A = [1 7 0; 4 2 1;8 2 1; 2 4 1; 9 4 0];
C3 = A(:,3) == 1;                                           % Logical Vector For Rows Meeting Condition
Compare = A(C3,1) ./ A(C3,2)                                % ‘Compare’ By Division
Use any method for comparing them that you want. I chose element-wise division here to demonstrate the approach.
Experiment to get the result you want.
2 件のコメント
その他の回答 (0 件)
参考
カテゴリ
				Help Center および File Exchange で Verification, Validation, and Test についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

