How to combine 3 for loops into one?
8 views (last 30 days)
I have the following code, which I would like to create a loop for but I have 3 variables that I would like to change.
I have made a loop with one variable where i change the columns but not sure how I can do it like this
The code below is just an example but I need to do this for a much larger range of about 50 for my image.
Star Strider on 8 Feb 2020
Rv = [54:56; 69:71; 39:41; 84:86]; % Row Start Matrix
Cv = 16:18; % Column Vector
Rc = 0:15; % Row Subscript Address Length
for k = 1:3
% Q1 = [Rv(1,k)+Rc; Rv(3,k)+Rc] % Check Addressing (Delete)
% Q2 = [Rv(2,k)+Rc; Rv(4,k)+Rc] % Check Addressing (Delete)
I(Rv(1,k)+Rc,Cv(k)) = I(Rv(3,k)+Rc, Cv(k));
I(Rv(2,k)+Rc,Cv(k)) = I(Rv(4,k)+Rc, Cv(k));
This works for the code you posted. You will need to expand the ‘Rv’ and ‘Cv’ vectors for the rest of your image. (The ‘Q1’ and ‘Q2’ variables make the addressing visible when you un-comment them. Delete them when you no longer need them.)