write script( a for loop that multiplies all evens numbers from 2 to 10)

5 Ansichten (letzte 30 Tage)
sothuon thorn
sothuon thorn am 24 Okt. 2016
Bearbeitet: Andrei Bobrov am 24 Okt. 2016
Please help

Antworten (2)

Andriy Kavetsky
Andriy Kavetsky am 24 Okt. 2016
x=2:10;
x=x(mod(x,2)==0)
res=1;
s=size(x)
for i=1:s(1) for j=1:s(2)
res=res*x(i,j);
end
end

Andrei Bobrov
Andrei Bobrov am 24 Okt. 2016
Bearbeitet: Andrei Bobrov am 24 Okt. 2016
prod(2:2:10);

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by