Matrix dimensions do not match

4 visualizaciones (últimos 30 días)
Laura Dunn
Laura Dunn el 7 de Dic. de 2023
Respondida: Star Strider el 7 de Dic. de 2023
trying to plot three variables and I am getting an error message about the dimensions. I have z as a 19x1 double, jd as a 19x1 double and cor1 as a 19x16 double. I did a transpose and ran into the same error.
figure;
pcolor(jd,z,cor1');
datetick('x',15,'keepticks','keeplimits')
shading flat
clim([0 400]);
colorbar
title('cor1')
Error using pcolor
Matrix dimensions must agree.

Respuestas (2)

Voss
Voss el 7 de Dic. de 2023
From pcolor documentation:
"pcolor(X,Y,C) specifies the x- and y-coordinates for the vertices. The size of C must match the size of the x-y coordinate grid. For example, if X and Y define an m-by-n grid, then C must be an m-by-n matrix."
In your case, jd and z define a 19-by-19 grid (since they both are 19x1), but cor1 is not 19x19 (it's 19x16) and neither is cor1' (it's 16x19).

Star Strider
Star Strider el 7 de Dic. de 2023
Either ‘z’ or ‘jd’ has to be a (16x1) double for that to work.
That discrepancy is throwing the dimension error.
.

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by