在matlab中创建直方图电影

时间:2017-03-28 12:27:13

标签: matlab matlab-figure matlab-guide

我使用下面的代码在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的数字。我怎么能这样做?

1 个答案:

答案 0 :(得分:0)

做的:

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