Matlab - 轨迹的累积分布

时间:2016-02-02 03:56:28

标签: matlab function histogram distribution motion

据我所知,我在问题的答案中找不到任何答案。我认为自己在Matlab中相当不错。

我记录的肿瘤轨迹与时间like on this image有关。我想计算累积分布,该分布将显示肿瘤从x = 0 like on this picture generated with another software处理想位置的时间与位移的关系。

累积图表意味着我们可以找到肿瘤在采集期间所花费的特定位置之外的总时间。你可以看到肿瘤在0位置的位置是整个采集时间的长度(~300秒)。如果我们正在寻找肿瘤在理想位置1.1毫米以外的时间,则表明~100秒肿瘤在2.8mm以外的时间变得非常接近0。

任何可以帮助我获得这样的代码都会很棒。我强烈感觉到与cumsum,cdf等有关,但我真的没有找到一个合适的功能。我的下一个选择是自己装箱并为其编写代码。

谢谢你的帮助。

1 个答案:

答案 0 :(得分:0)

您可以使用hist(x)查找分发。然后通过计算向后cumsum(),您可以绘制所需的图。

clc, clear all, close all
seconds = 303;              % Amount of time that passed during the test
datapoints = 3000;          % Amount of Datapoints in your vector 

x = randn(datapoints,1);
[counts,centers] = hist(abs(x),sort([0;unique(abs(x))]));

sumX = sum(counts);
cumsumX = cumsum(counts);
time = (sumX - [0 cumsumX(1:end-1)])*seconds/datapoints; % Normalize result with factor

figure
plot(centers, time)