Can we list all possible values for a property of a MATLAB object without going via help/doc ?

조회 수: 1 (최근 30일)
To be clear, I will be specific, but the question is for the general case (the more general, the better)
Consider that you have a graphics object, say axes with handle axH. You wish to set the 'NextPlot' property of that object to something else than the default value, but you cannot recall the possible notation to do so... Hence, you must open the documentation to find the acceptable values. In a perfect MATLAB world, it would be better to be able to do something similar to 'get', for example:
>> axH = axes();
>> getPossibleValues(axH.NextPlot)
ans =
'replace'
'add'
'replaceall'
'replacechildren'

채택된 답변

Walter Roberson
Walter Roberson 2017년 1월 8일
Not in any simple form, no. For graphics objects and for a number of other different kinds of objects, there is a method:
axH = axes();
set(axH,'NextPlot')
4×1 cell array
'add'
'replace'
'replacechildren'
'replaceall'
and when you do not know the property name:
set(axH)
ALim: {}
ALimMode: {'auto' 'manual'}
ActivePositionProperty: {'position' 'outerposition'}
AmbientLightColor: {1×0 cell}
Box: {'on' 'off'}
BoxStyle: {'full' 'back'}
[...]
This only displays non-hidden properties, and only works for objects that use the get/set interface. It does not, for example, work for Java objects.
  댓글 수: 2
Ronny Landsverk
Ronny Landsverk 2017년 1월 8일
편집: Ronny Landsverk 2017년 1월 8일
@Walter: Thanks for rapid response. It is surprising to me that 'set' with no property value will return those
Image Analyst
Image Analyst 2017년 1월 8일
Some properties do not have a discrete set of potential values, for example the xlim() property of an axes. The value could be virtually anything (excep +/- infinity).

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by