Does findpeaks work with mat files?

1 Ansicht (letzte 30 Tage)
Fran
Fran am 5 Jul. 2019
Kommentiert: Star Strider am 6 Jul. 2019
Hi there
I have a very simple question. Does findpeaks work with matfile variables?
I run the following example below and I don't get any errors but my script doesn't detect any peaks. Essentially nothing happens if I run the following.
EPSCs_PYR_1= load('mytrace2131soma&syns.mat', 'mytrace2131syns');
EPSCs_PYR = mytrace2131syns(:,2);
time=mytrace2131syns(:,1);
findpeaks(EPSCs_PYR,time);
What do I do wrong? Similar scripts have worked in the past if I load .dat or .txt files
thank you!
  2 Kommentare
Stephen23
Stephen23 am 5 Jul. 2019
Bearbeitet: Stephen23 am 5 Jul. 2019
You load the .mat file into a structure named EPSCs_PYR_1, but you never actually use EPSCs_PYR_1 for anything or refer to it again. Whatever data is imported from that file is ignored by your code.
Fran
Fran am 5 Jul. 2019
Hello
that's a good point I will investigate, however it is not entirely true that the variable imported (mytrace2131syns) is ingnored by my code because I can plot this variable just fine using the script below. It is the peak detection that doesn't work on these data.
EPSCs_PYR_1= load('mytrace2131soma&syns.mat', 'mytrace2131syns');
EPSCs_PYR = mytrace2131syns(:,2);
time=mytrace2131syns(:,1);
findpeaks(EPSCs_PYR,time);
plot(time,EPSCs_PYR);

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Stephen23
Stephen23 am 5 Jul. 2019
Bearbeitet: Stephen23 am 5 Jul. 2019
Most likely you need to actually refer to the structure that you imported the file data into:
S = load('mytrace2131soma&syns.mat', 'mytrace2131syns');
T = S.mytrace2131syns(:,1);
V = S.mytrace2131syns(:,2);
pks = findpeaks(V,T)
  1 Kommentar
Fran
Fran am 5 Jul. 2019
thanks, that looks more correct than what I did previously, however it produces the same output. The script plots my trace but the peakdetection on the trace doesn't work.

Melden Sie sich an, um zu kommentieren.


Star Strider
Star Strider am 5 Jul. 2019
... my script doesn't plot my trace and doesn't detect any peaks ...
You are overwriting the findpeaks plot.
Try this instead:
figure
findpeaks(EPSCs_PYR,time);
figure
plot(time,EPSCs_PYR);
Both plots should now appear in their respective figure objects.
  8 Kommentare
Fran
Fran am 6 Jul. 2019
Bearbeitet: Fran am 6 Jul. 2019
I installed R2019a but our administator hasn't send me the licenses to update my matlab server yet, thus the R2019a is too new for my existing license files. I am now installing R2018b for the next month or so, at least until I update the server. I will let you know how it goes!
PS: in terms of updates, following your instructions everything appeared to be up-to-date in my previous 2017 version.
Star Strider
Star Strider am 6 Jul. 2019
Please do!
I have no idea what the problem with findpeaks is in your R2017 installation. I never had any problems with it.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by