Shi*_*iva 0 matlab plot graph cdf matlab-figure
我cdfplot
在 matlab 中使用来绘制某些数量的经验 CDF。
[h,stats]=cdfplot(quantity)
Run Code Online (Sandbox Code Playgroud)
现在stats
返回一个具有最小值、最大值、平均值等的结构。我希望这些值在图表中显示为文本。
我有很多类似的图表要绘制,不想手动绘制。
要在绘图上放置文本,请使用该text
函数。这是一个情节的快速示例:
y = evrnd(0,3,100,1);
[h, stats] = cdfplot(y);
hold on
x = -20:0.1:10;
f = evcdf(x,0,3);
plot(x,f,'m')
legend('Empirical','Theoretical','Location','NW')
stat_type = {'min: ';'max: ';'mean: ';'median: ';'std: '}; % make titles
stat_val = num2str(struct2array(stats).'); % convert stats to string
text(-15,0.7,stat_type) % <-- here
text(-11,0.7,stat_val) % <-- and here
hold off
Run Code Online (Sandbox Code Playgroud)
这将给出:
并且您可以在循环中使用它来为所有图形执行此操作。
棘手的事情是定义在图表上放置文本的位置。这里我选择 (-15,0.7) 和 (-11,0.7) 作为我知道没有数据的固定点。你应该看看你的情节,并找到正确的地方。