How to obtain each each maximum value from each signal set?
25 views (last 30 days)
Show older comments
Hi all
Because I am doing a special flow cytometry and I got 8 sets of wave, which means 1 set of wave is 1 cell pass through my sensor.
Now, I want to know how to pick up the maximum amplitude from each sets of wave?
Plus, are there any method to prevent double pick if one set of wave have same max value?
Thanks!
10 Comments
Peng Li
on 30 Apr 2020
Sorry didn't log on these days. quite stressful working from home...
see below an example using your synthetic data
%% Your Generate signal Copied here
fs = 1e9;
tc = gauspuls('cutoff',10e3,0.5,[],-40);
t = -tc:1/fs:tc;
x = gauspuls(t,10e3,0.5);
ts = 0:1/50e3:0.025;
d = [0:1/1e3:0.025;sin(2*pi*0.1*(0:25))]';
y = pulstran(ts,d,x,fs);
plot(ts,y)
xlim([0 0.01])
%% segmentation
baseline = ismembertol(y, 0, 1e-3);
% convert 0-1 series baseline to segments
incl = baseline ~= 1;
incT = diff([0; incl(:); 0]);
stId = find(incT == 1);
edId = find(incT == -1) - 1;
seg = [stId(:) edId(:)];
% you could possibly add some condition here to filter out segments that is
% too short
% alternatively (better), you find the between-waves segments, and add
% conditions to check the length of these segments. If too short, this
% might be a wrong detection and you delete it to merge the two waves
% let me know if this is clear for you
%% with each segment, detect maximum
% can use for, or arrayfun for better readability
pind = nan(size(seg, 1), 1);
for iS = 1:size(seg,1)
[~, ind] = max(y(seg(iS, 1):seg(iS, 2)));
pind(iS) = ind + seg(iS, 1) - 1;
end
hold on;
plot(ts(pind), y(pind), 'ro');
Accepted Answer
Star Strider
on 16 Apr 2020
You have the Signal Processing Toolbox, so use the findpeaks function to get the peak amplitudes. It has a number of options so you can be certain to get only the values you want. If you want to get the amplitudes of the ‘valleys’ use findpeaks on the negative value of the signal vector.
10 Comments
Star Strider
on 18 Apr 2020
I do not understand. If you want to do this in real time, I doubt MATLAB is capable of tha. That might require additional hardware. If so, I will not be able to help you with it.
If you are only interested in recorded signals, there are several functions that might be able to help you with that, including findchangepts, and ischange.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!