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

4 visualizzazioni (ultimi 30 giorni)
Wendell
Wendell il 25 Giu 2017
Commentato: John BG il 27 Giu 2017
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 Commento
John BG
John BG il 27 Giu 2017
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.

Accedi per commentare.

Risposte (1)

Walter Roberson
Walter Roberson il 25 Giu 2017
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.

Categorie

Scopri di più su Colormaps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by