Filter löschen
Filter löschen

Assign a Name for Each Iteration

1 Ansicht (letzte 30 Tage)
Amanda
Amanda am 9 Mai 2013
I'm trying to assign a name for each iteration in a for loop. Let's take the fundamental for loop:
for i = 1:3
x = i^2
end
And the the output is:
x = 1;
x = 4;
x = 9;
What I want to do is assign the x's as x(1),x(2), and x(3). So what I'm trying to achieve is to have a for loop output as:
x(1) = 1;
x(2) = 4;
x(3) = 9;
Thanks,
Amanda

Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 9 Mai 2013
Bearbeitet: Azzi Abdelmalek am 9 Mai 2013
for i = 1:3
x(i) = i^2
end

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