Hello Mark,
It is my understanding that you are looking for setting the 'CData' property of multiple images the same. It would be helpful to know the exact context in which you faced the error message CData fields must be the same size, for addressing the root cause. However, in general, the error message indicates that the 'CData' matrices of the image objects you are trying to assign are not of the same size.
For example, to create three distinct figures with the same 'CData' but different image objects, you need to ensure that the 'CData' matrices have the same size. Here is an example how you could do that:
imageData = randi([0, 255], 100, 100);
axes1 = axes('Parent', figure1);
imageObject1 = image(imageData, 'Parent', axes1);
colormap(axes1, colormapData);
axes2 = axes('Parent', figure2);
imageObject2 = image(imageData, 'Parent', axes2);
colormap(axes2, colormapData);
axes3 = axes('Parent', figure3);
imageObject3 = image(imageData, 'Parent', axes3);
colormap(axes3, colormapData);
isCDataSame = isequal(imageObject1.CData, imageObject2.CData, imageObject3.CData);
disp('The cdata is the same for all three images.');
disp('The cdata is different for the images.');
end
The cdata is the same for all three images.
In case you are referring to the error message in the context of animation, I suggest you visit the answer of the following MATLAB Answer:
I hope this helps!