saving . . . saved Iteration has been deleted. Iteration has been hidden .
Iteration
Title
Question
How to find summation of vector x = [1 2 6 4 2], using iterative procedure. Hint: Check length(), add each number using ‘for’ loop. 

Scilab Iteration 05-06 min 10-20 sec 13-05-20, 2:20 a.m. deepali0225@gmail.com

Answers:

As per the hint, find the length of vector 'x' and store it in some variable, here in 'y', for ease. Then write the for loop as follows to get the desired output:

x = [1 2 6 4 2]
y=length(x)
s=0;
for i=1:y
    s = s + x(i)
    disp(s)
end
13-05-20, 11:05 a.m. rashpat93


Log-in to answer to this question.