Using if condition store values in an array
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Waqas Siddique
am 19 Feb. 2021
Bearbeitet: Walter Roberson
am 20 Feb. 2021
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)
1 Kommentar
Akzeptierte Antwort
the cyclist
am 19 Feb. 2021
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!