for loop question

4 Ansichten (letzte 30 Tage)
raymond
raymond am 28 Nov. 2011
hello i'm trying tom make my for loop iterate 100,1000,10000 and 100000 times using this code
n=[1 2 3 4]
for i=1:1:100.^n
r= i
end
for some reason it only iterates once can someone tell me why please and help me fix it

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 28 Nov. 2011
n = 1:4;
r = cell2mat(arrayfun(@(x)1:10*10^x,n,'un',0));

Weitere Antworten (0)

Kategorien

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

Community Treasure Hunt

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

Start Hunting!

Translated by