Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to manipulate the output of a for loop to get the sum of the output data set

Status
Not open for further replies.

shegmite

Member level 1
Joined
Apr 8, 2012
Messages
33
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,496
Please i need hint on how to manipulate the output from a for loop do summation of differences between it and a data set one at a time. An example is shown below. I tried it but it only computed for the first for loop data 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)
 

Hi shegmite,

you need to store the result of each iteration in a different location.
A must be a vector.
Like this:

A=zeros(1,4);
ii=1;
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(ii)=(sum(Y)*Z);
ii=ii+1;
end
disp(A)

Regards

Z
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top