필터 지우기
필터 지우기

How can I use function call?

조회 수: 2 (최근 30일)
Haksun Lee
Haksun Lee 2012년 7월 10일
Hello! I always appreciate all help~
I want to know how to call another function in main code.
For instance, I have 'set' function of 5 lines in GUI code such as following. set(handles.text1,'String','1'); set(handles.text2,'String','2'); set(handles.text3,'String','3'); set(handles.text4,'String','4'); set(handles.text5,'String','5');
In here, I'd like to 5 lines with just one line using function call. ~~~ abc(); %function call ~~~
function abc() set(handles.text1,'String','1'); set(handles.text2,'String','2'); set(handles.text3,'String','3'); set(handles.text4,'String','4'); set(handles.text5,'String','5');
I tried above code but I can't handles at another function. How can I call another function in main code and use handles and variable of main code at another function?
I need your help.... Thank you for reading...
  댓글 수: 1
Jan
Jan 2012년 7월 10일
Please format your code properly: Mark it and hit the "{} code" button.

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

답변 (2개)

Mark Whirdy
Mark Whirdy 2012년 7월 10일
Hi Haksun
I assume you're working in GUIDE?
Pass handles into the sub-function so it is in-scope there (nested functions have caller scope, sub-functions don't). If this doesn't solve your issue then I'll need you to re-explain the problem as I'm not sure I get it.
function abc(handles)
set(handles.text1,'String','1');
set(handles.text2,'String','2');
set(handles.text3,'String','3');
set(handles.text4,'String','4');
set(handles.text5,'String','5');

Haksun Lee
Haksun Lee 2012년 7월 10일
Oh--- Thanks for all!
Your words are very helpful me..
I will try to do with reference answer!
Thank you...
  댓글 수: 1
Mark Whirdy
Mark Whirdy 2012년 7월 11일
can you hit "Accept" on the answer if you find it works for you
tnx Mark

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by