Does findpeaks work with mat files?

조회 수: 1 (최근 30일)
Fran
Fran 2019년 7월 5일
댓글: Star Strider 2019년 7월 6일
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