Propety of variable in one line matlab

조회 수: 1 (최근 30일)
Vatsal Shah
Vatsal Shah 2019년 8월 21일
댓글: Rik 2019년 8월 21일
I want to get a specific property (location in this case) of the variable that is returned from the function detectSURFFeatures in one line.
The following would work
temp = detectSURFFeatures(imgA, 'MetricThreshold', 1000);
features = temp.Location;
but I need to be able to get features using only one line of code like the
features=(detectSURFFeatures(imgA, 'MetricThreshold', 1000)).Location;
I was wondering if there was any way I would be able to do this

답변 (1개)

Rik
Rik 2019년 8월 21일
Why do you need one line? It is generally less readable if you try to write it like that.
But if you insist: the subsref function should do the trick.
  댓글 수: 2
Vatsal Shah
Vatsal Shah 2019년 8월 21일
I need it in one line because I plan on using that in the fun function for blockproc. I am unable to put multiple lines of code in the fun function for blocproc as far as I know. Thank you so much!
Rik
Rik 2019년 8월 21일
You can do it with subsref, but you can also supply a function handle (e.g. B=blockproc(A, sz, @mean2); ), so you can write any length function you like. Just make sure the input satisfies the restrictions of blockproc.

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

Community Treasure Hunt

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

Start Hunting!

Translated by