loop executing more then the given iteration.
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (3)
Amit
am 27 Dez. 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 Kommentare
Amit
am 28 Dez. 2013
Bearbeitet: Amit
am 28 Dez. 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 Kommentare
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements 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!