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 commentaires

madhan ravi
madhan ravi le 30 Nov 2018
Modifié(e) : madhan ravi le 30 Nov 2018
so when it satisfies the condition you mean you want to extract all the correponding rows/columns?upload the sample data and give an example of your desired output.
Samaneh Arzpeima
Samaneh Arzpeima le 30 Nov 2018
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 le 30 Nov 2018
just give a numerical example still not clear

Connectez-vous pour commenter.

 Réponse acceptée

Mark Sherstan
Mark Sherstan le 30 Nov 2018
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,:)

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Produits

Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by