Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2348
  • Last Modified:

Slice a Matlab Matrix (newbie question)

I have a 2col by 20,000 row matrix in matlab

A=
  .1    7
  .2    8
  .3    7
   .....
  2.1   12
  2.2   13

How do I slice matrix A so that matrix B contains only the pairings from A where col1>.3 and col1<2.1?

The matlab documentation talkes about how to do this with indexing.  But since this is a HUGE matrix, finding the indices will be difficult.
0
tmonteit
Asked:
tmonteit
2 Solutions
 
arturrrroCommented:
One solution below, probalby not the simplest one:
A([[A(:,1) >0.3] .* [A(:,2) < 2.1]]==1,:)

Open in new window

0
 
yuk99Commented:
Just another solution (probably the most obvious).

Indexing like this in Matlab is very fast even for the huge matrix. How huge is it by the way? I worked with millions records without much problems.


B=A(A(:,1)>0.3 & A(:,1)<2.1),:);

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now