how to extract data with some condition

조회 수: 49 (최근 30일)
Samaneh Arzpeima
Samaneh Arzpeima 2018년 11월 30일
댓글: Samaneh Arzpeima 2018년 11월 30일
Hello everyone
I have a 9 colomns of data,say x1 to x9, each colomn has 150 rows
I need to extract all the data when x2==0 and x1=0.5, and make a new dataset of 9 colomns
Please teach me how to do this
I will appreciate you help
  댓글 수: 3
Samaneh Arzpeima
Samaneh Arzpeima 2018년 11월 30일
That is right
for example when the 4th and 5th rows of x2 are 0 and x1 are 0.5
i should extract 4th and 5th rows of all 9 colomns and make a new data set
thank you
madhan ravi
madhan ravi 2018년 11월 30일
just give a numerical example still not clear

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

채택된 답변

Mark Sherstan
Mark Sherstan 2018년 11월 30일
Try the code below. You will have to change it to your data but you should get the idea.
% Generate a random matrix of intergers between 1 and 3
x = randi(3,[250 9]);
% Find where there are 1's in column one and 3's in column two for each row
row = find( x(:,1)==2 & x(:,2)==3 );
% Build a new matrix A that satisfies the condition of 1's and 3's
A = x(row,:)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Weather and Atmospheric Science에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by