cdata fields must be the same size error
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
N/A
le 30 Oct 2023
Réponse apportée : Sudarsanan A K
le 8 Nov 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.
https://www.mathworks.com/help/matlab/ref/matlab.graphics.primitive.image-properties.html
0 commentaires
Réponse acceptée
Sudarsanan A K
le 8 Nov 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.');
else
disp('The cdata is different for the images.');
end
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!
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Lighting, Transparency, and Shading dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!