2011-11-30 36 views
0

我正在使用MATLAB,并调用返回屏幕属性的函数。请看下面:列表/配对数组:访问一个元素

>> Screen('resolution', 0) 

ans = 

    width: 1280 
    height: 1024 
pixelSize: 32 
     hz: 60 

这很好,但我只想访问'宽度'参数。我不知道这是一种“配对数组”还是简单的列表,但基本上我有兴趣提取第一个元素;宽度'。

任何想法?

回答

4

您从Screen获得的答案是struct类型的数组。你的access the fields of a structure arrayvariableName.fieldName语法。

screenInfo = Screen('resolution',0); 

%# access width 
width = screenInfo.width 
0

getfield(Screen('resolution', 0),'width')