How to overlay Min and Max values onto a plot, then calculate exponential decay between Min and Max points.

3 views (last 30 days)
Hello,
I have a set of data that I collected which consists of 25 repetitions of a stimulus with a constant duration (3ms), with a short delay period (1.5ms) in between each stimulus presentation (See attached screenshot).
During each of the 25 stimulus presentations, I have a minimum and maximum value that I'm interested in identifying with a ('*') marker, fitting an exponential from the Min to the Max, and then plotting the value of the exponential over the course of the 25 stimuli.
So far, I've managed to calculate the Min and Max for each of my 25 stimuli, and I would like to overlay these onto my current data plot (second plot in the screenshot) and subsequently fit with an exponential.
It seems like I need to expand the size of my array for my calculated Mins and Maxes by inserting some zeroes or something so they match the length of my current array, but I am unsure of the best way to do this. I am also unsure of how to fit a single exponential between these two values (for each of the 25 stimuli)
Here's my code and screenshot of what I'm trying to do. Any help regarding how I should tackle this would be appreciated. I can also send you my raw data if that will help. Thanks!
%Define Channels and Sampling Rate
currentCh = 1;
voltageCh = 2;
stimCh = 3;
sampleRate = 100000;
%Navigate to Folder
ci_dir=uigetdir;
cd(ci_dir);
%Folder Contents '.abf'
contents = dir('*.abf');
filenames = {contents.name}';
jcFiles = fullfile(cd, filenames);
%Load jclampFiles with structure [Ch1, Ch2, Ch3]
jcData = abfload(jcFiles{1});
%Generate the X scale (in ms) according to sampleRate
x = 1:length(jcData(:,currentCh));
x = x/sampleRate;
%Find peak and ending current
CurrentData = jcData(:,1)
IntTime = 3000
DelayTime = 1500
NumInt = (length(CurrentData))/(DelayTime+IntTime)
for i = 1:(NumInt)
q = ((i)*(DelayTime+IntTime)+1)-3000
y = (i)*(DelayTime+IntTime)+1
MinVal(i) = min(CurrentData(q:y))
end
for i = 1:(NumInt)
q = ((i)*(DelayTime+IntTime)+1)-3000
y = (i)*(DelayTime+IntTime)+1
MaxVal(i) = max(CurrentData(q:y))
end
%Plot currentCh and stimCh data vs. time
figure();
subplot (4,1,1);
PlotAllEpisodes(x, jcData, stimCh); %Plot stim voltage vs. time
xlabel('Time (s)');
ylabel('Piezo Voltage (V)');
subplot (4,1,2);
PlotAllEpisodes(x, jcData, currentCh); %Plot MET current vs. time
xlabel('Time (s)');
ylabel('Current (nA)');
subplot(4,1,3)
plot(MinVal, 'r')
xlabel('Stim Number')
ylabel('Peak Current (nA)')
subplot(4,1,4)
plot(MaxVal, 'r')
xlabel('Stim Number')
ylabel('Ending Current (nA)')

Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!