## Could anyone help me how to solve the issue.

### jaah navi (view profile)

on 16 Apr 2019
Latest activity Edited by Stephen Cobeldick

on 16 Apr 2019

### Stephen Cobeldick (view profile)

how to add all the values generated using for loop
for example
A=[1 2],[3 4],[7 5 6]
for i=1:length(A)
value% i am using formula to calculate the value
end
In this code first it run for [1 2] generates a value-(a)
then it run for [3] generates a value-(b)
then it run for [4 5 6] and generates a value-(c)
Now i want to add (a)+(b)+(c) after the end statement so i tried with the follwing command sum(value,:) but unable to get the result.

### Stephen Cobeldick (view profile)

on 16 Apr 2019
Edited by Stephen Cobeldick

### Stephen Cobeldick (view profile)

on 16 Apr 2019

Using very basic MATLAB indexing:
A = {[1,2],[3,4],[7,5,6]};
N = numel(A);
Z = nan(1,N);
for k = 1:N
Z(k) ... your code using A{k}
end
sum(Z)
@ jaah navi: you have been using MATLAB since 2017, loops and indexing are very basic programming concepts that you should definitely learn yourself, they are explained in the introductory tutorials:

jaah navi

### jaah navi (view profile)

on 16 Apr 2019
i tried but unable to get the result.
in my code
length = 1:5
for
need to take 1st length and compute value-(a)
.. -(b)
.. -(c)
.. -(d)
need to take 5th length and compute value-(e)
end
now i need to add all the values together which means a+b+c+d+e
jaah navi

### jaah navi (view profile)

on 16 Apr 2019
with respect to your sample code
A = {[1,2],[3,4],[7,5,6]};
N = numel(A);
Z = nan(1,N);
for k = 1:N
Z(k) ... your code using A{k}
end
sum(Z)
The code is for A={[1,2],[3,4],[7,5,6]};
in the same manner i have different numbers for A
for example
when
A = {[1,2],[3,4],[7,5,6]};
the output can be obtained by sum(Z)
when A={[4 5 ],[1 3 4]
i can get the output by sum(Z)
now i need to add both sum(Z)