Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How i save the value of c in deach loop and sum these value after each value then using value in another eq outside loop??

2 visualizaciones (últimos 30 días)
Let say i have this simple loop,,
for i=1:3
A=x((i-1)*3+1);
B=x((i-1)*3+2);
C=x((i-1)*3+3);
Z=A*B+C*A;
end
i want the value of C in each loop to be sum and then using it in this eq let say,
W=E-C
because the value of C are different in each loop.
Thanks ^_^.

Respuestas (1)

Mahdi
Mahdi el 5 de Jun. de 2014
Say E=3;
for i=1:3
A(i)=x((i-1)*3+1);
B(i)=x((i-1)*3+2);
C(i)=x((i-1)*3+3);
Z(i)=A*B+C*A;
W=E-sum(C);
end
  2 comentarios
ali
ali el 5 de Jun. de 2014
Hi mahdi,
i used this form but still not working as i want because the Z is constraint!! Thank you.
Mahdi
Mahdi el 5 de Jun. de 2014
Editada: Mahdi el 5 de Jun. de 2014
What do you mean you want the Z as constraint? Can you explain what you want output to be in more detail please? Or give an example with numbers?

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by