我正在使用MATLAB,并调用返回屏幕属性的函数。请看下面:列表/配对数组:访问一个元素
>> Screen('resolution', 0)
ans =
width: 1280
height: 1024
pixelSize: 32
hz: 60
这很好,但我只想访问'宽度'参数。我不知道这是一种“配对数组”还是简单的列表,但基本上我有兴趣提取第一个元素;宽度'。
任何想法?
我正在使用MATLAB,并调用返回屏幕属性的函数。请看下面:列表/配对数组:访问一个元素
>> Screen('resolution', 0)
ans =
width: 1280
height: 1024
pixelSize: 32
hz: 60
这很好,但我只想访问'宽度'参数。我不知道这是一种“配对数组”还是简单的列表,但基本上我有兴趣提取第一个元素;宽度'。
任何想法?
您从Screen
获得的答案是struct
类型的数组。你的access the fields of a structure array与variableName.fieldName
语法。
screenInfo = Screen('resolution',0);
%# access width
width = screenInfo.width
getfield(Screen('resolution', 0),'width')