Does findpeaks work with mat files?

1 次查看(过去 30 天)
Fran
Fran 2019-7-5
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 个评论
Stephen23
Stephen23 2019-7-5
编辑:Stephen23 2019-7-5
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 2019-7-5
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);

请先登录,再进行评论。

回答(2 个)

Stephen23
Stephen23 2019-7-5
编辑:Stephen23 2019-7-5
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 个评论
Fran
Fran 2019-7-5
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.

请先登录,再进行评论。


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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Grid Lines, Tick Values, and Labels 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by