Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
For Loop (or if-condition) is ignoring the first value
    1 visualizzazione (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
Hello everybody, like I mentioned I´ve got the problem, that the first value is ignored (the first value of the matrix 'auftraege'):
for j=1:n_pop
    for i=1:n_auf*n_lkw
        for k=1:n_auf
            if matrix(j,i)==auftraege(k,1) 
                matrix(j,i)=auftraege(k,2);
            end
        end
    end
end
     2     0     0     0     3     0     0     5     1     4
     1     0     0     0     4     0     0     2     1     1
If I use this code and set k to k=2:n_auf I get the same solution as mentioned above.
for j=1:n_pop
    for i=1:n_auf*n_lkw
        for k=1:n_auf
            if matrix(j,i)==auftraege(1,1) 
                matrix(j,i)=auftraege(k,2);
            end
        end
    end
end
     0     0     5     4     0     1     0     3     0     2
     0     0     5     4     0     4     0     3     0     2
As you can see: When I put the number 1 directly into the if condition, the solution for the 1 is correctly. After these tests I think the problem is that the for loop starts with k=2 and not k=1. Do you think I´m right with my guessing? Or do you even got a solution?
Thanks everybody
0 Commenti
Risposte (0)
Questa domanda è chiusa.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
