matrix column element limiting
1 次查看(过去 30 天)
显示 更早的评论
hi,
I have a matrix say 200*30. I need to limit the elements of 29th and 30th columns with different constraints. how can I do that?
thanks,
0 个评论
采纳的回答
Azzi Abdelmalek
2015-7-8
Example
A=rand(200,30)
idx=A(:,29)>0.5 & A(:,30)<0.7
out=A(idx,:)
4 个评论
Stephen23
2015-7-8
编辑:Stephen23
2015-7-8
Azzi Abdelmalek's solution is much more optimized than using a loop. This is how MATLAB works best, using basic code vectorization and indexing.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Optimization Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!