Retrieve loop counter values in nested loop, and plotting specific calculation
Mostrar comentarios más antiguos
Hello all. My questions are as commentated
count = 0 ;
vec = zeros([],7) ;
for a=1:3
A= 2*a ;
for b=a+1:6
B=3*b ;
for c=b+1:10
C=4*c ;
count = count+1 ;
total=sum([A B C])
vec(count,:)=[a b c A B C total];
end
end
end
value = max(total) % get max and return values of a,b,c when this happens
% plotting corresponding individual calculation A B C for the max(total)
end
4 comentarios
dpb
el 14 de Ag. de 2018
[vmax imax] = max(vec(:,end)) % get max and return values of a,b,c when this happens
vec(imax,:) contains the desired quantities.
Not sure what you want to do regarding a plot for a single point?
Pit Probst
el 15 de Ag. de 2018
Editada: Pit Probst
el 15 de Ag. de 2018
Adam Danz
el 15 de Ag. de 2018
I don't follow your explanation. However, when I run your code I get an error on the first iteration since
[a b c A B C total]
has 10 elements but
vec(count,:)
expects 11 elements. On the 2nd iteration there are 11 elements in [a b c...] so there isn't an error.
Pit Probst
el 15 de Ag. de 2018
Editada: Pit Probst
el 15 de Ag. de 2018
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Exponents and Logarithms 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!