필터 지우기
필터 지우기

How to operate > and > to extract a matrix?

조회 수: 2 (최근 30일)
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD 2017년 11월 17일
댓글: MAHMOUD ALZIOUD 2017년 11월 19일
Dear all, I have a matrix and i need to extract a smaller matrix based on a condition, this condition took the following shape as Mr Walter once advised me, xab and xbc and xcd are from different columns, but when i run it i found that the new matrix Qua1 took a value that is larger than 6 ! how can i fix this please.
mask1 = xab(:,1)<6 & xbc(:,1)<6 & xcd(:,1)<6;
Qua1=M(mask1, :);

채택된 답변

Image Analyst
Image Analyst 2017년 11월 18일
편집: Image Analyst 2017년 11월 18일
You are getting a mask for this situation
  1. column 1 of xab is less than 6, AND
  2. column 1 of xbc is less than 6, AND
  3. column 1 of xcd is less than 6
In other words, where all 3 columns of those 3 different arrays are less than 6.
mask1 could be false if any of the x matrices were more than 6 but not all 3, for example 2 were 5 but one of them was 7. Qua1 should not take that row however since mask1 would be false there for that row.
Then you are taking rows where that is the case from M. However, the values of M can be ANYTHING and have no relation to what the values of the x matrices are. The values in M could be up in the millions.
If you want to clip Qua1 to 6, then you can do this:
Qua1(Qua1>=6) = 6;
  댓글 수: 7
Image Analyst
Image Analyst 2017년 11월 19일
They ARE being applied at the same time. Let's make the 3 conditions more explicit so you can see that:
condition1 = 0.1*3.28084*M(:,8) < 6
condition2 = 0.1*3.28084*M(:,10) < 6
condition3 = 0.1*3.28084*M(:,12) < 6;
% Find out which rows meet ALL 3 conditions at the same time.
all3Conditions = condition1 & condition2 & condition3;
% Extracts ALL columns in M but only
% in those rows meeting all 3 conditions.
Qua1 = M(all3Conditions , :);
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD 2017년 11월 19일
you are more than amazing, I will give it a try, thank you very much

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by