Matlab files polyval?

조회 수: 7 (최근 30일)
George Ghimire
George Ghimire 2020년 8월 16일
답변: Walter Roberson 2020년 8월 16일
Hi I have a code but could anybody tell me what does this code mean
Question 1.
Beta = polyval(Results.data1,0);
Results is my matfiles which contains 'data1' field inside with two values 12 and 15.
i have seen the help on ployval. for example Beta = polyval(p,x) This will evaluate p at x. Just wanted to know what will be the value of p in my above case since i have two values 12 and 15. Is my p=12x+15?
What is the result of Beta?
Question 2.
Delta = @(im_) polyval(Results.data2,im_);
Inthis case i didnot understande anything. In this case data2 contains three values 4, 5 and 7.
What will be the results of Delta and what actually is im_ in this case

채택된 답변

Walter Roberson
Walter Roberson 2020년 8월 16일
i have two values 12 and 15. Is my p=12x+15
Yes. And in particular in your code, that would be evaluated with x = 0
Delta = @(im_) polyval(Results.data2,im_);
In this case i did not understand anything. In this case data2 contains three values 4, 5 and 7.
Then that would be the polynomial 4*x^2 + 5*x + 7
What will be the results of Delta
Delta will not be a numeric value. Delta will be a "function handle". When you invoke Delta passing in a numeric parameter, then at the time you invoke it, the value that you pass in will be passed to polyval as the x for polynomial 4*x^2 + 5*x + 7 . For example,
Delta(-1:1)
would cause the polyomial to be evaluated for x = -1, x = 0, and x = 1
what actually is im_ in this case
im_ in this context is what is referred to as a "dummy argument". It stands in for whatever value is eventually passed in to the function handle. In the example Delta(-1:1), during the execution of the function handle body, im_ would temporarily be [-1 0 1] . If you were to then call Delta(7) then during the execution of the body of the function handle, im_ would be temporarily 7.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Geometric Transformation and Image Registration에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by