Matrix dimensions do not match

4 Ansichten (letzte 30 Tage)
Laura Dunn
Laura Dunn am 7 Dez. 2023
Beantwortet: Star Strider am 7 Dez. 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.

Antworten (2)

Voss
Voss am 7 Dez. 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 am 7 Dez. 2023
Either ‘z’ or ‘jd’ has to be a (16x1) double for that to work.
That discrepancy is throwing the dimension error.
.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by