loop executing more then the given iteration.
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
i am calling one function inside the loop,in 1st iteration function calling and returning gud result,but when i have given more then one iteration(more then one function call),i am getting multiple result,loop should run only two time ,but its running three times.
it is because of function call inside the loop.
for y=1:count1 result(1)=comb(1); switch(y) case 1 for z=1:2 result(y+1)=acid(z); index=y+1; funcomb(index,result,acid); end end % switch end end
Any solution to this problem ?
0 commentaires
Réponses (3)
Amit
le 27 Déc 2013
There are 2 loops. Loop y and loop z.
The only time switch is activating is for y = 1 ( I dont understand the purpose of that for y=1:count1 loop??) Inside the case 1, the loop is running twice however both times it is doing the same thing as they are are related to outer loop index, which will remain 1.
Can you post you results where you having trouble? That might help. And a little explanation of the purpose - I am only asking because it seems from this code that the loops are unnecessary here.
0 commentaires
Amit
le 28 Déc 2013
Modifié(e) : Amit
le 28 Déc 2013
This might be a little help for what you trying to do.
To be honest, I am a bit confused looking at your code. I am trying to justify the for loop along with switch? The switch only evaluates the first time in the loop and does not do anything afterwards.
Also, am I correct in saying that from a [L/M-A-A-A-A-A-Y-A-A-A-A-A-K/N] expression, with A = [A B C D E], you want sequences where the second term is A and the 3 term is Y and last term is K? [LAYAK], [LAYABK] etc etc?
0 commentaires
Voir également
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!