how to manipulate the output of a for loop to get the sum of the output data set
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
segun
el 15 de Abr. de 2014
Comentada: segun
el 15 de Abr. de 2014
Please i need hint on how to manipulate the output from a for loop do summation of differences between it and a data set. An example is shown below. I tried it but it only computed for the first for loop neglecting the other data set.
for f = [1 4 8 10];
b=2;
c=1;
d=1;
n=4;
N= f*b*c*d
M=[4.5 10 20 25];
Y = (M-N)/M;
Z=(100/n);
A =(sum(Y)*Z);
end
disp(A)
0 comentarios
Respuesta aceptada
Mischa Kim
el 15 de Abr. de 2014
Editada: Mischa Kim
el 15 de Abr. de 2014
Segun, are you trying to compute the cumulative sum?
A = 0;
for f = [1 4 8 10]
b = 2; c = 1; d = 1; n = 4;
N = f*b*c*d;
M = [4.5 10 20 25];
Y = (M-N)/M;
Z = 100/n;
A = A + sum(Y)*Z;
end
disp(A)
3 comentarios
Mischa Kim
el 15 de Abr. de 2014
Could you be more specific? What are your inputs and what is the expected output?
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!