How to find values from data
Mostrar comentarios más antiguos
When using if statements, I am trying to find a set of data that fits the condition I have given. How can I find where the data with the right conditions is located?
Respuestas (1)
You can use logical indexing.
Example:
A = rand(10,1) ; % data for demo
idx = A > 0.3 & A < 0.8 ;
idx
find(idx)
A(idx)
5 comentarios
Zach Hanses
el 12 de Dic. de 2021
You can go by logical indexing seperately; need not to use a if condition. If you insist:
A = rand(10,1) ;
for i = 1:10
if A(i) > 0.3 && A(i) < 0.8 % condition
A(i) % do this
end
end
Zach Hanses
el 12 de Dic. de 2021
Star Strider
el 12 de Dic. de 2021
What are the row and column sizes are the two data sets? Do they have common times (or any other specific identifying row information)?
Zach Hanses
el 12 de Dic. de 2021
Categorías
Más información sobre Cell Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!