How can I extract the values from a 5000x2 matrix?

2 views (last 30 days)
how can I extract the values from a 5000x2 matrix ( X and Y values) where the pairs of X and Y is (<-,-1) U (1, ->). So that I can a vector with the X values where the properties are fullfilled and a vector with the Y values where the properties are fullfilled.
clear;
clc;
rng(6039);
mu = 0;
sigma = 1;
n = 5000;
Xsim = normrnd(mu, sigma, n);
Ysim = normrnd(mu, sigma, n);
X = Xsim(:,1);
Y = Ysim(:,1);
XY = [X Y];
  2 Comments
Jan
Jan on 15 Nov 2018
Edited: Jan on 15 Nov 2018
I do not understand the meaning of "(<-,-1) U (1, ->)"
Please use the methods to format code properly.
madhan ravi
madhan ravi on 19 Nov 2018
If you close the question will be deleted after 10 days so the effort of the answerer becomes useless , keep in mind

Sign in to comment.

Accepted Answer

Jan
Jan on 15 Nov 2018
Maybe:
index = (X < -1 & Y > 1);
XY = [X(index), Y(index)]
  2 Comments
Jan
Jan on 15 Nov 2018
"Doesn't work" is not a useful description of a problem.
Perhaps you want this:
index = (X < -1 & Y < -1) | (X > 1 & Y > 1);

Sign in to comment.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!