Get handle of subplot with CData
2 views (last 30 days)
Show older comments
Christopher Grose
on 18 Oct 2018
Answered: Walter Roberson
on 18 Oct 2018
The following throws a 'There is no CData property on the Axes class' error, but I don't know how to resolve it.
% initiate figure and get subplot handles
ynum = 100;
xnum = 100;
xgrid = 0:1:(xnum-1);
ygrid = 0:1:(ynum-1);
figure(2); hold on;
subplot(2,2,1); imagesc(xgrid,ygrid,zeros(ynum,xnum)); caxis([0 0.75]); colormap(jet(256)); colorbar; title('0');
subplot(2,2,2); imagesc(xgrid,ygrid,zeros(ynum,xnum)); caxis([0 1.00]); colormap(jet(256)); colorbar; title('phase field (P1)');
subplot(2,2,3); imagesc(xgrid,ygrid,zeros(ynum,xnum)); caxis([0.15 0.85]); colormap(jet(256)); colorbar; title('comp field (A)');
subplot(2,2,4); imagesc(xgrid,ygrid,zeros(ynum,xnum)); caxis([1 1000]); colormap(jet(256)); colorbar; title('crystal field');
handles.img(1) = subplot(2,2,1); truesize;
handles.img(2) = subplot(2,2,2); truesize;
handles.img(3) = subplot(2,2,3); truesize;
handles.img(4) = subplot(2,2,4); truesize;
hold off;
% update figure
for t=1:10
figure(2);
set(handles.img(1),'CData',rand(ynum,xnum)); title(num2str(t));
set(handles.img(2),'CData',rand(ynum,xnum));
set(handles.img(3),'CData',rand(ynum,xnum));
set(handles.img(4),'CData',rand(ynum,xnum));
end
0 Comments
Accepted Answer
Walter Roberson
on 18 Oct 2018
subplot(2,2,2); handles.img(2) = imagesc(xgrid,ygrid,zeros(ynum,xnum)); caxis([0 1.00]); colormap(jet(256)); colorbar; title('phase field (P1)');
0 Comments
More Answers (0)
See Also
Categories
Find more on Subplots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!