How do I make this matlab code to plot multiple figures in subsequent 'while' iterations ?

조회 수: 3 (최근 30일)
Hi. I'm a beginner in Matlab, I'm working on Image analysis and I think this code segment is supposed to display a plot in a figure everytime the if condition is met. I'M 100% sure that the if condition is met more than once but the program only gives a figure output the first time the if condition is met. It does not gives outputs when the if condition is met in subsequent iterations. It also does this wierd thing where it dsplays the first figure but without the plot in it and only displays the corresponding plot in the figure when the program has finished running. Like I said, I'm a beginner and I have a feeling that this is a minor problem but I just can't figure it out.Please any help will be appreciated. To be clear, I'm trying to plot different data in different figures whenever the if condition is met but it only plots the first time the if condition is met and does nothing in subsequent times.
  댓글 수: 3
chris oj
chris oj 2018년 12월 18일
Thank you Sir. I used drawnow just now and it solved the problem of the program running to completion before plotting in the first figure. But I still can't see the subsequent figures (and their plots) that should be displayed when the if condition is met. Also how exactly do I use figure(), can you write the syntax for me? Thank you very much.
Omer Yasin Birey
Omer Yasin Birey 2018년 12월 18일
If you see only the first figure, probably the condition is getting met just once. Or maybe you are just seeing the last figure?

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

채택된 답변

Omer Yasin Birey
Omer Yasin Birey 2018년 12월 18일
편집: Omer Yasin Birey 2018년 12월 18일
You should write figure() for every if statement to display corresponding image. So, just write at the begining of the statement like this. As far as I understand you want seperate images thats why I believe hold off should be inside the if.
if ref_image{f,3} == inactivity_time
figure
axis image;
disp(n)
imshow(originalImage_new);
hold on;
plot_pixels = ref_image{f,1};
plot(plot_pixels(:,1),plot_pixels(:,2),'*r');
hold off
end
  댓글 수: 1
chris oj
chris oj 2018년 12월 18일
Wow. It works well now. I added draw now to display outputs immediately. Then I added to figure to display multiple outputs on different figures. Though there was something else I had to change in my code to make it work. Thanks guys. I really appreciate!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by