Matlab - 尝试引用非结构数组

时间:2015-12-18 02:08:45

标签: arrays matlab

我正在从事与植被检测有关的项目,我正在按照Matlab的这个教程来计算NDVI。

Finding Vegetation in a Multispectral Image

但我有一个错误,我不知道为什么会发生这种错误。 这是代码:

% Create a figure with a 1-by-2 aspect ratio
h = figure;
p   = h.Position;
h.Position = [p(1,1:3),p(3)/2];
subplot(1,2,1)
% Create the scatter plot
plot(red, NIR, '+b')
hold on
plot(red(q(:)), NIR(q(:)), 'g+')
ax = gca;
ax.XLim = [0 1];
ax.YLim = [0 1];
axis square
xlabel('red level')
ylabel('NIR level')
title('NIR vs. Red Scatter Plot')
% Display the thresholded NDVI
subplot(1,2,2)
imshow(q)
h.Colormap = [0 0 1; 0 1 0];
title('NDVI with Threshold Applied')

这就是错误:

???尝试引用非结构数组的字段。

==>中的错误teste_nir at 51

p = h.Position;

有人能帮助我吗?

1 个答案:

答案 0 :(得分:0)

根据您使用的Matlab版本,您可能需要使用以下内容:

p = get(h,'Position');