필터 지우기
필터 지우기

What is a handle?

조회 수: 1 (최근 30일)
Cheuk Yin Wong
Cheuk Yin Wong 2022년 6월 30일
댓글: Cheuk Yin Wong 2022년 7월 2일
I always see the word 'handle' in the matlab community but I don't quite understand what is it even I search it online. I am an absolute begineer of matlab, can anyone please give me a simple explaination or direct me to the right resource. Thank you.

채택된 답변

Steven Lord
Steven Lord 2022년 6월 30일
What's the context in which you see that term? There are at least three different meanings for that term, though two of them are somewhat related.
  • Handle as related to graphics? Start with this documentation page. Graphics handles let you manipulate graphics objects on screen; for example if I have a line's handle I can change its Color property and so change what color it is.
h = plot(1:10, 1:10); % h is the line's handle. By default it is blue.
figure % Let's make a second line so you can see the difference when I change its color
h2 = plot(1:10, 1:10);
h2.Color = 'r'; % Let's make this line red
  • Handle in terms of object-oriented programming? See here, though this is often thought of as an advanced skill for MATLAB programming. Graphics handles are handle objects, though not all handle objects are graphics objects.
  • Handle as related to evaluating a function, like with an ODE solver or optimization routine? Those are function handles, which are useful in passing a "reference" to function A into function B so that function B can call function A with input arguments of its choice.
f = @sin;
Find a zero of the function y = sin(x). Start looking at 1. fzero will call f with points of its choosing as it looks for a solution.
x = fzero(f, 1)
x = 1.5485e-24
To check, evaluate the function handle yourself at the point fzero found.
shouldBeCloseTo0 = f(x)
shouldBeCloseTo0 = 1.5485e-24
That's pretty close to 0.
  댓글 수: 1
Cheuk Yin Wong
Cheuk Yin Wong 2022년 7월 2일
Thank you very much! This is very clear.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by