![](/img/trans.png)
[英]Matlab Code only Calculating number of pixels and not their sum, if pixel value falls above given Threshold value
[英]Calculating time of first and last value above threshold
为此,您可以使用查找function。 我不知道这是否可以实现为 Simulink function 块,我对 Simulink 毫无头绪:
% fake some data
t = 0:200;
signal = 100*exp(-((t - 100)/50).^2) + randn(1,201)*10;
% plot signal
plot(t, signal);
threshold = 50;
% find first above threshold
ind1 = find(signal > threshold, 1, 'first');
% find last above threshold
ind2 = find(signal > threshold, 1, 'last');
% plot it
hold on;
plot([1 1] * t(ind1), [0 100], 'r-', [1 1] * t(ind2), [0 100], 'r-');
鉴于t
, signal
和threshold
有你谈论的数据,另一个选择是:
getfield(t(signal>threshold),{[1 sum(signal>threshold)]})
这将为您提供时间t
的第一个和最后一个值,其中signal>threshold
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.