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

 채택된 답변

Image Analyst
Image Analyst 2014년 7월 22일

0 개 추천

Try
images = fliplr(images); % or flipud() - what ever works.
Or
images = images(end:-1:1);

댓글 수: 3

mika maka
mika maka 2014년 7월 22일
thanks that works, but what about the for loop, is it not possible for it have two variables? I don't quite understand why this does not work.
Joseph Cheng
Joseph Cheng 2014년 7월 22일
편집: Joseph Cheng 2014년 7월 22일
*cough* well if you take a look at the answer below. you can see how to get 2 variables to work. why your nested (is that the right term?) for loop doesn't really do what you want is because it'll do all combination of m for each j. so for j=1 you'll run through it for m=3,2,1 and then for j=2 you'll run through it again for m=3,2,1 and so on.
Joseph Cheng
Joseph Cheng 2014년 7월 22일
편집: Joseph Cheng 2014년 7월 22일
Oh and additionally thinking about it more you could have had
m=length(images);
for j = 1:3
imagesc(images{m+1-j}, '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

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Joseph Cheng
Joseph Cheng 2014년 7월 22일
편집: Joseph Cheng 2014년 7월 22일

1 개 추천

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

카테고리

도움말 센터File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

질문:

2014년 7월 22일

편집:

2014년 7월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by