Matlab error "Z must be size 2x2 or greater"
1 次查看(过去 30 天)
显示 更早的评论
Can anyone help me with this code, I kept on getting a error (Z must be size 2x2 or greater),
% Plot contours of ground-level Zn concentration.
figure(1)
clist = [ 0.001, 0.01, 0.02, 0.05, 0.1 ];
glc2 = glc*1e6; % convert concentration to mg/m^3
[c2, h2] = contourf( xmesh, ymesh, glc2, clist );
clabel(c2, h2, 'FontSize', smallfont-2 )
colormap(1-winter)
colorbar
set(gca, 'XLim', xlim ), set(gca, 'YLim', ylim )
xlabel('x (m)'), ylabel('y (m)')
title(['Zn concentration (mg/m^3), max = ', sprintf('%5.2f', max(glc2(:)))])
grid on
The error reads like this:
Error using contourf (line 66)
Z must be size 2x2 or greater.
Error in forward2 (line 47)
[c2, h2] = contourf( xmesh, ymesh, glc2, clist );
I would appreciate any advise
Thanks much.
1 个评论
John BG
2017-6-27
both contour and contourf
require at least input Z.
Your variable glc is not same size as X and Y, it's not a Z with same size as X and Y, please define glc as used so far.
回答(1 个)
Walter Roberson
2017-6-25
You have
glc2 = glc*1e6; % convert concentration to mg/m^3
but we have no idea what size glc is. Whatever it is is likely either a scalar or a vector instead of being a 2D array that is at least 2 x 2.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Contour Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!