# Simple for and if loop got wrong...

3 vues (au cours des 30 derniers jours)
buer le 11 Déc 2014
Commenté : buer le 11 Déc 2014
Hi,
My mind looks like got some water...I just can not figure out what is wrong with this.
for i=1:100,
if(((data_cell{i,1})<= time)&&((data_cell{i+1,1})> time))
[row,col]=find(data_cell{i,1});
end
end
I just want to find the value point, where data{i,1}is samller than time, and data {i+1,1}is bigger than time... but the result always gives the last value until i is 100... It should find the value and stop the loop...anyone please give some idea...
Thanks.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Guillaume le 11 Déc 2014
You appear to be very confused indeed about the usage of find. Assuming that data_cell{:, 1} and time are scalar, and assuming that data_cell{:, 1} is monotonically increasing
data_col1 = cell2mat(data_cell(:, 1));
thresholdpoint = find(data_col1 > time, 1);
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
buer le 11 Déc 2014
Thanks so much Guillaume, it works..I will check again find function....:D

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by