访问XData,YData,ZData,CData时可能出现的Matlab补丁错误

时间:2019-05-29 21:53:28

标签: matlab patch

突然我无法正确访问补丁内的数据。这发生在不同的,单独的计算机上,以前未引发错误的未修改代码。我找不到解释,希望有人给我答案。以下说明不再对我有用:

选项1)

% get the patches in axes object
vector_patches = findobj(ax, 'Type','patch');

% we get for example the first patch
h_patch = vector_patches(1)

% display the x-y-z coordinates in column-wise: sometimes appears no data, other times it recovers succesfully the x and y, but not z..
disp([h_patch.XData', h_patch.YData', h_patch.ZData']) 

选项2)

% another way of accesing the data
vec_children = ax.Children; % get axes children

% we take the first object of vector. if it is patch...
if strcmp(get(vec_children(1),'Type','patch')),'patch')
    h_pat = vec_children(1);

    % then we extract in another way the data using get
    x_dat = get(h_pat,'XData');
    y_dat = get(h_pat,'YData');
    z_dat = get(h_pat,'ZData');

end %endif

% finally we try to display the results...
disp([x_dat', y_dat', z_dat'])

它一直对我有用,但是从今天开始,在不同的计算机,环境和matlab版本上,它都可以工作了更长的时间:(有人可以解释原因吗?在此先感谢

0 个答案:

没有答案