how to write for loop with two variables
Show older comments
Hello, I'm having problem with this it of code:
for j = 1:3
for m = 3:-1:1
imagesc(images{m}, 'XData', [fid1(j,1) (size(Image1,2) + fid1(j,1))], 'YData',[fid2(j,1) (size(Image1, 1) + fid2(j,1))]), axis equal, axis xy
alpha(0.7)
hold on
end
end
As you can see, I want the images{m} to start from 3 and end at 1, while the fid1(j,1) commands to go in the opposite direction. Any ideas how to solve this? One idea I had was to flip my images{m} array but I'm not sure how to do this
Thanks
Accepted Answer
More Answers (1)
Joseph Cheng
on 22 Jul 2014
Edited: Joseph Cheng
on 22 Jul 2014
make an array called index = 3:-1:1;
for j = 1:3
m=index(j);
imagesc(images{m}, 'XData', [fid1(j,1) (size(Image1,2) + fid1(j,1))], 'YData',[fid2(j,1) (size(Image1, 1) + fid2(j,1))])
axis equal
axis xy
alpha(0.7)
hold on
end
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!