你好,我试图创建变量Wkinet在不同时间j的直方图(这是某些粒子的能量分布随时间变化的方式),但我想为1)对于每个时间步都不考虑零。值2)结果是在一张图表中获取每个时间值的所有histfit,但仅拟合而不是条形3)我也希望在y轴上对其进行归一化
nbins=100;
for j=1:ntM
idxToKeep = Wkinet(:,j ) ~= 0;
Wkinet2 = Wkinet(idxToKeep,:);
y=Wkinet2(:,j).*erg2eV;
histfit(y,nbins)
hold on
delete(h(2))% deletes histogram
end
hold off
end
答案 0 :(得分:-1)
erg2eV = 6.2415e11;
ntM=500;
myTolerance=1e-15; % in erg units.
nbins=1000;
for j=1:ntM/10:ntM
hold on
myFit = fitdist((Wkinet_eV(Wkinet_eV(:,j)>myTolerance, j) ), 'Normal');
maxEv = max(Wkinet_eV(Wkinet_eV(:,j)>myTolerance, j));
minEv = min(Wkinet_eV(Wkinet_eV(:,j)>myTolerance, j)); %also
myX = minEv: (maxEv-minEv)/nbins: maxEv;
myY = pdf(myFit, myX);
loglog((myX),( myY)); %maybe just plot or %plot(log10(myX),myY)
ylim([10^-13,1])
pause;
end