I have a matrix and I am actually interested in obtaining a vector that will consist of the first column in each row that has values lower certain value.
1 回表示 (過去 30 日間)
古いコメントを表示
I have a matrix and I am actually interested in obtaining a vector that will consist of the first column in each row that has values lower 3. e.g if I have A=[ 5 7 8 3 2 ;6 2 1 4 4;1 2 3 4 5; 4 5 2 1 3]. I expect an Ans: [5;2;1;4]
0 件のコメント
採用された回答
Saint
2017 年 5 月 29 日
編集済み: Saint
2017 年 5 月 29 日
その他の回答 (1 件)
MathReallyWorks
2017 年 5 月 27 日
Hello saint,
Your question is not clear. Please edit it.
By the description of your question I can guess that you want first column of each row provided that entry is less than 3. In that case this code works well:
A = [ 5 7 8 3 2 ;6 2 1 4 4;1 2 3 4 5; 4 5 2 1 3];
newA = A(A(:,1)<3,1)
But, then you said you are expecting [5;2;1;4] which is contradictory to your question.
[5;6;1;4] is possible as it contains all first element.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!