Matlab error "Z must be size 2x2 or greater"

조회 수: 4 (최근 30일)
Wendell
Wendell 2017년 6월 25일
댓글: John BG 2017년 6월 27일
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
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
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.

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by