Using if condition store values in an array
7 次查看(过去 30 天)
显示 更早的评论
I have a list of numbers stored as double type in a variable B. I want to use if condition so that if the value of element in B is greater than or equal to 12, I want to store all those values in another array named C.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/525064/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/525064/image.png)
采纳的回答
the cyclist
2021-2-19
If I understand you correctly, this does what you want. (It doesn't directly use "if", but does the job via logical indexing instead.)
C = B(B>=12);
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!