can i call app designer CallBack Functions outside the app ?
조회 수: 9 (최근 30일)
이전 댓글 표시
hello
i want to know if it is possible to call for example
buttonpushedcallback()
from an external .m script
so i want to process some data in my matlab script then i call callbacks functions
i tried this
a=myapp
a.buttonpushedcallback(a)
but it gave me error no class or public property called buttonpushedcallback in myapp
댓글 수: 0
답변 (1개)
Adam
2017년 4월 12일
편집: Adam
2017년 4월 12일
Yes, it is possible, but you need to understand the basics of function scope.
a=myapp
a.buttonpushedcallback(a)
would be wrong in all contexts. You either put a. at the front or you pass a in as an argument, you don't do both because they amount to the same thing so you would be passing it in twice, as the first two arguments with this syntax.
You use
a.buttonpushedcallback( )
or
buttonpushedcallback( a )
if a is an object of a class and buttonpushedcallback is a method of that class. For a method that is not part of the class you just call
buttonpushedcallback( )
If you really want you can have a method that is external to the class that still takes an object of it as first argument:
buttonpushedcallback( a )
but you cannot use the a.buttonpushedcallback syntax here. Quite why you would want to do this I don't know, since if it takes the class object as argument it should be a method of the class in general, but it is possible.
For a callback though you generally need to pass in two arguments representing the source and event data though also for it to be recognised as a valid callback signature.
댓글 수: 5
Adam
2018년 4월 20일
That sounds like you just ave a syntax error somewhere above that in your code. Check for a missing 'end' from previous functions or method blocks. Selecting everything (e.g. Ctrl + A) and then auto-indenting with Ctr + I can help you to easily spot missing 'end' statements.
Sarah Bell
2018년 4월 22일
Thank you so much! This just fixed my code, and now I can not only submit it 14+ hours early but I'm probably going to get the best mark I've ever had on any coding based coursework, so thank you again!
While I have you here, my boyfriend is also doing coding coursework and was wondering if you happen to know anything about the Kernighan-Lin (or KL) algorithm in Matlab?
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!