필터 지우기
필터 지우기

set execution points in your code

조회 수: 4 (최근 30일)
nida
nida 2014년 4월 21일
편집: Joseph Cheng 2014년 4월 21일
ihave a code which gives multiple output images,i access them from gui and view it on axes,i want to show those images one at a time by setting point in my code where only on pressing a button from gui should execute and display output image for that set of code. (what i mean is code is to be divided into segments.when ipress a button on gui ist segment should execute,when i press again 2nd segment should execute and on and on)

답변 (1개)

Joseph Cheng
Joseph Cheng 2014년 4월 21일
Simple way to do this would be that separating the sections of code into switch/case statement where you would stick each segment of code into each case and increment a value at the end of the button press.
function button_Callback(_______)
switch ButtonPressedNtimes
case 1
%section of code for first button press
%store values for second button press
case 2
%section of code for second button press
%store values for third button press
case 3
%section of code for third button press
%store values for next button press
%etc.
end
ButtonPressedNtimes=ButtonPressedNtimes+1;
Troubles that can occur is that you need to make sure you are storing the appropriate variables in their correct state for the next processing. Also you can use mod() to get the button presses to loop after the user hits the button multiple times.
  댓글 수: 3
nida
nida 2014년 4월 21일
편집: nida 2014년 4월 21일
what call would you give for each segment of codes(codes are in different m file), what are values,im new to this.the thing is i have separate button to start executing that code,but when i reach that point i want another button to take over
Joseph Cheng
Joseph Cheng 2014년 4월 21일
편집: Joseph Cheng 2014년 4월 21일
you would call them whatever you want?
you would write your button callback to process only sections of code that you can select and separate by the switch/case statements. There shouldn't be an issue of each segment is in a different m file. you would just use them as you would normally.
if you check out their example you can see what these things can do. http://www.mathworks.com/help/matlab/ref/switch.html

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

카테고리

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

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by