-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpeakanalysis.m
More file actions
54 lines (46 loc) · 1.33 KB
/
peakanalysis.m
File metadata and controls
54 lines (46 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function [minTime, minValue, maxTime, maxValue] = peakanalysis(time, voltage, threshold)
% Find and analyze time and value of peaks in a trace
%
% Input:
% time = Time of a peak
% voltage = Voltage of the peak
% threshold = Threshold above which a peak must be to be analyzed;
% set this based on what it looks like it should be from
% a preliminary plot of your data
%
%
% Output:
% minTime = Vector of times at which minimum peaks occur
% minValue = Vector of value at minimum peaks
% maxTime = Vector of times at which maximum peaks occur
% maxValue = Vector of values at maximum peaks
minTime = [];
minValue = [];
maxTime = [];
maxValue = [];
% Use peakdet function to find mins and maxs
[maxtab, mintab] = peakdet(voltage, threshold, time);
% Separate the mintab and maxtab into two respective
% arrays by variable (time of peak and value of peak)
if mintab ~= 0
minTime = mintab(:,1);
minValue = mintab(:,2);
elseif mintab == 0
minTime = 0;
minValue = 0;
end
if maxtab ~= 0
maxTime = maxtab(:,1);
maxValue = maxtab(:,2);
elseif maxtab == 0
maxTime = 0;
maxValue = 0;
end
% Plot the traces and distinctly label the maxima and minima
%plot(time,voltage)
%hold on
%plot(minTime,minValue,'bo')
%plot(maxTime,maxValue, 'ro')
%ylabel('Current (pA)')
%xlabel('Time')
%hold off