how to declare two variables together in the for loop

how to declare two variables together in the for loop

1 Comment

It works the exact same way as outside a loop. The only thing to keep in mind is that the loop is repeated, so your assignment might be overwritten.

Sign in to comment.

Answers (1)

R = 1:4;
C = 2:5;
for k = 1:numel(C)
r = R(k);
c = C(k);
...
end

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Asked:

on 6 Jan 2018

Commented:

Rik
on 6 Jan 2018

Community Treasure Hunt

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

Start Hunting!