Matlab error "Z must be size 2x2 or greater"
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
John BG
el 27 de Jun. de 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.
Respuestas (1)
Walter Roberson
el 25 de Jun. de 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.
0 comentarios
Ver también
Categorías
Más información sobre Colormaps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!