From: Paul doherty on 12 Jul 2010 09:43 I'm pretty new to MATLAB coding. I have a matrix with multiple rows (the number varies) and 3 columns. That looks something like the following: 1 2 5 1.3 4 1 1.4 2 2 1.5 3 3 I'm sure this is really simple, but how do I reduce the matrix down. Specifically the first column contains increasing numbers. Depending on the application, I will want the matrix to contain numbers that will be below a specific number X (eg. 1.4). So I want to reduce the matrix down to: 1 2 5 1.3 4 1 However the number X changes for different applications and the matrix is massive. Any help greatly appreciated?
From: Frédéric Bergeron on 12 Jul 2010 09:52 Hey, I think this line may helps you. X=1.4; B=A(A(:,1)<X,:); Fred
From: Andy on 12 Jul 2010 09:56 "Paul doherty" <dohertyp(a)gmail.com> wrote in message <i1f65c$apr$1(a)fred.mathworks.com>... > I'm pretty new to MATLAB coding. I have a matrix with multiple rows (the number varies) and 3 columns. That looks something like the following: > 1 2 5 > 1.3 4 1 > 1.4 2 2 > 1.5 3 3 > > I'm sure this is really simple, but how do I reduce the matrix down. Specifically the first column contains increasing numbers. Depending on the application, I will want the matrix to contain numbers that will be below a specific number X (eg. 1.4). So I want to reduce the matrix down to: > > 1 2 5 > 1.3 4 1 > > However the number X changes for different applications and the matrix is massive. Any help greatly appreciated? A; % your n x 3 matrix x = 1.4; % your desired cutoff number idx = A(:,1) < x; % get the row indices where the first column is less than x B = A(idx,:); % return only those rows where the first column is less than x
From: us on 12 Jul 2010 09:57 "Paul doherty" <dohertyp(a)gmail.com> wrote in message <i1f65c$apr$1(a)fred.mathworks.com>... > I'm pretty new to MATLAB coding. I have a matrix with multiple rows (the number varies) and 3 columns. That looks something like the following: > 1 2 5 > 1.3 4 1 > 1.4 2 2 > 1.5 3 3 > > I'm sure this is really simple, but how do I reduce the matrix down. Specifically the first column contains increasing numbers. Depending on the application, I will want the matrix to contain numbers that will be below a specific number X (eg. 1.4). So I want to reduce the matrix down to: > > 1 2 5 > 1.3 4 1 > > However the number X changes for different applications and the matrix is massive. Any help greatly appreciated? one of the many solutions m=[ 1 2 5 1.3 4 1 1.4 2 2 1.5 3 3 ]; r=m(m(:,1)<1.5,:) us
From: someone on 12 Jul 2010 09:59 "Paul doherty" <dohertyp(a)gmail.com> wrote in message <i1f65c$apr$1(a)fred.mathworks.com>... > I'm pretty new to MATLAB coding. I have a matrix with multiple rows (the number varies) and 3 columns. That looks something like the following: > 1 2 5 > 1.3 4 1 > 1.4 2 2 > 1.5 3 3 > > I'm sure this is really simple, but how do I reduce the matrix down. Specifically the first column contains increasing numbers. Depending on the application, I will want the matrix to contain numbers that will be below a specific number X (eg. 1.4). So I want to reduce the matrix down to: > > 1 2 5 > 1.3 4 1 > > However the number X changes for different applications and the matrix is massive. Any help greatly appreciated? % One solution: x = [1 2 5;1.3 4 1;1.4 2 2;1.5 3 3]; X = 1.35; y = x(x(:,1)<X,:) y = 1.0000 2.0000 5.0000 1.3000 4.0000 1.0000
|
Next
|
Last
Pages: 1 2 Prev: Using OpenMP with cpp Next: How to save a Affymetrix cel file in matlab? |