Pcolor Plot returning error Color data input must be a matrix.

17 views (last 30 days)
Gurpreet Sidhu
Gurpreet Sidhu on 10 May 2022
Commented: VBBV on 10 May 2022
I keep getting the above error with my code, i am trying to use the pcolor funtion to plot cell dominance, from z which is a 546x1 double.
x1 = 1:26;
y1 = 1:21;
[X1,Y1] = meshgrid(x1,y1);
z = Ind(:,1);
i = pcolor(x1, y1, z);

Answers (1)

VBBV
VBBV on 10 May 2022
Edited: VBBV on 10 May 2022
h = pcolor(X1, Y1, z); % use X1, Y1 instead of x1 , y1, z must be 21x26 matrix
  2 Comments
VBBV
VBBV on 10 May 2022
x1 = 1:26;
y1 = 1:21;
[X1,Y1] = meshgrid(x1,y1);
z = rand(21,26)
z = 21×26
0.1888 0.9982 0.2816 0.2672 0.7953 0.1147 0.6820 0.3750 0.8584 0.4191 0.6513 0.5506 0.3321 0.8901 0.6155 0.7335 0.1466 0.2384 0.0171 0.5042 0.2394 0.4561 0.3932 0.2752 0.6974 0.1031 0.4723 0.8583 0.8495 0.9722 0.8484 0.9573 0.9113 0.8421 0.7342 0.2141 0.8557 0.9822 0.0389 0.7136 0.2123 0.5461 0.6856 0.2915 0.4596 0.5401 0.4219 0.3357 0.4511 0.4680 0.9062 0.9302 0.8884 0.3787 0.3886 0.3494 0.3853 0.4297 0.8085 0.1674 0.2468 0.2919 0.8885 0.6969 0.5496 0.3333 0.2768 0.2268 0.1724 0.9669 0.6768 0.2383 0.8403 0.3709 0.9975 0.8570 0.4686 0.4797 0.7542 0.9777 0.4084 0.7667 0.6565 0.9964 0.6452 0.4857 0.2114 0.2795 0.2712 0.1581 0.0282 0.7049 0.3910 0.5266 0.2310 0.7170 0.4156 0.5564 0.2319 0.7203 0.6903 0.4689 0.5080 0.6725 0.0708 0.4481 0.2072 0.5526 0.1250 0.2533 0.8394 0.8890 0.4680 0.2118 0.6384 0.7210 0.5506 0.1634 0.8253 0.5629 0.4149 0.7974 0.3239 0.8546 0.5702 0.9668 0.3816 0.8181 0.6979 0.8209 0.2177 0.4071 0.7707 0.0964 0.2662 0.7966 0.0310 0.9695 0.4748 0.7575 0.5161 0.8137 0.9029 0.8458 0.1024 0.9861 0.6043 0.4503 0.1990 0.5854 0.6034 0.0120 0.1755 0.8278 0.6379 0.2990 0.2316 0.0929 0.3398 0.2779 0.6366 0.8083 0.0270 0.0752 0.1256 0.2551 0.8479 0.6320 0.6736 0.3915 0.6401 0.4456 0.9486 0.6970 0.8398 0.3892 0.4578 0.7566 0.1164 0.5244 0.4540 0.9588 0.9550 0.3150 0.3080 0.8580 0.2221 0.6122 0.9120 0.3432 0.6728 0.3726 0.8293 0.4377 0.1408 0.3379 0.0531 0.9126 0.9365 0.8051 0.7888 0.7231 0.6959 0.0759 0.6114 0.5676 0.9433 0.2048 0.4366 0.2252 0.9743 0.0459 0.3417 0.8460 0.6047 0.9179 0.5167 0.3725 0.6212 0.6349 0.9735 0.2232 0.0884 0.6001 0.0553 0.1379 0.0765 0.4224 0.0661 0.8758 0.0332 0.7527 0.1574 0.8150 0.1330 0.5853 0.0180 0.9696 0.1872 0.0895 0.0429 0.0119 0.9494 0.1353 0.1568 0.1998 0.8354 0.5755 0.2522 0.3130 0.0366 0.7725 0.4321 0.9243 0.7337 0.2372 0.1757 0.2391 0.3821 0.9804
h = pcolor(X1, Y1, z);

Sign in to comment.

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!