Does findpeaks work with mat files?

4 visualizzazioni (ultimi 30 giorni)
Fran
Fran il 5 Lug 2019
Commentato: Star Strider il 6 Lug 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 Commenti
Stephen23
Stephen23 il 5 Lug 2019
Modificato: Stephen23 il 5 Lug 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 il 5 Lug 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);

Accedi per commentare.

Risposte (2)

Stephen23
Stephen23 il 5 Lug 2019
Modificato: Stephen23 il 5 Lug 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 Commento
Fran
Fran il 5 Lug 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.

Accedi per commentare.


Star Strider
Star Strider il 5 Lug 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 Commenti
Fran
Fran il 6 Lug 2019
Modificato: Fran il 6 Lug 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 il 6 Lug 2019
Please do!
I have no idea what the problem with findpeaks is in your R2017 installation. I never had any problems with it.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by