在 matlab 中创建直方图电影



我使用以下代码在 Matlab 中创建两部直言图电影:

h1 = figure
hold on
vid = VideoWriter('graph.avi');open(vid);
for t=1:time
figure(h1); 
cla
hist(eighsum(t,:),40)
currFrame = getframe(h1); 
writeVideo(vid,currFrame);
end
close(vid);

h2 = figure
hold on
video = VideoWriter('graphh.avi');open(video);
sizeclu = cell(1,size(clustersize,2));
for i = 1:numel(sizeclu)
sizeclu{i} = [clustersize{:,i}];
figure(h2);
cla
hist(sizeclu{i})
currFrame = getframe(h2); % gets only figure 2
writeVideo(video,currFrame);
end
close(video);

我希望直方图中不显示小于 1 的数字。我该怎么做?

do:

[counts,centers] = hist(eighsum(t,:),40);
centers(counts < 1) = [];
counts(counts < 1) = [];
bar(centers,counts);

最新更新