[英]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.