Borrar filtros
Borrar filtros

cdata fields must be the same size error

14 visualizaciones (últimos 30 días)
Mark el 30 de Oct. de 2023
Respondida: Sudarsanan A K el 8 de Nov. de 2023
What are the proper commands to make cdata the same for multiple figures? I've tried to look in the Mathworks documentation and there is no apparent direction about this issue.

Respuesta aceptada

Sudarsanan A K
Sudarsanan A K el 8 de Nov. de 2023
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:
% Create the indexed image data
imageData = randi([0, 255], 100, 100); % Replace with your actual indexed image data
% Create the colormap
colormapData = jet(256); % Replace with your desired colormap
% Create the first figure
figure1 = figure;
axes1 = axes('Parent', figure1);
imageObject1 = image(imageData, 'Parent', axes1);
colormap(axes1, colormapData);
% Create the second figure
figure2 = figure;
axes2 = axes('Parent', figure2);
imageObject2 = image(imageData, 'Parent', axes2);
colormap(axes2, colormapData);
% Create the third figure
figure3 = figure;
axes3 = axes('Parent', figure3);
imageObject3 = image(imageData, 'Parent', axes3);
colormap(axes3, colormapData);
% Check if the cdata is the same for all three images
isCDataSame = isequal(imageObject1.CData, imageObject2.CData, imageObject3.CData);
% Display the result
if isCDataSame
disp('The cdata is the same for all three images.');
disp('The cdata is different for the images.');
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!

Más respuestas (0)


Más información sobre Graphics Object Programming 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!

Translated by