I have a matrix A=[1 2 3; 1 2 9; 2 3 4]. I want a matrix B whose column 1 is equal to 1. How can I do this? B=[1 2 3; 1 2 9]
5 views (last 30 days)
Show older comments
I have a matrix A=[1 2 3; 1 2 9; 2 3 4]. I want a matrix B whose column 1 is equal to 1. How can I do this? B=[1 2 3; 1 2 9]
0 Comments
Accepted Answer
dpb
on 8 May 2014
B=A(A(:,1)==1,:);
Lookup "logical addressing" in documentation for details on how this works--it's important Matlab syntax.
More Answers (1)
Image Analyst
on 10 May 2014
You say "I have a matrix A=[1 2 3; 1 2 9; 2 3 4]. I want a matrix B whose column 1 is equal to 1. How can I do this? B=[1 2 3; 1 2 9]" You just gave the answer in the question itself! The answer is
B=[1 2 3; 1 2 9];
Read your question. The matrix A is not involved AT ALL in how you came up with B. No criteria or tests were to be applied to A, so A can just be ignored.
0 Comments
See Also
Categories
Find more on Resizing and Reshaping 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!