Does available funtion in Matlab can extract rows satisfied a condition?
1 次查看(过去 30 天)
显示 更早的评论
I want to create a matrix has rows has first column value = 4 from matrix a; like
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/367906/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/367909/image.png)
Does available funtion in Matlab can extract rows satisfied a condition? Thanks so much!
0 个评论
采纳的回答
Ameer Hamza
2020-9-28
编辑:Ameer Hamza
2020-9-28
Read about array indexing: https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html and https://www.mathworks.com/help/matlab/math/array-indexing.html
a = [4 5 6;
4 5 6;
5 5 6];
idx = a(:,1)==4;
b = a(idx, :);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!