Does findpeaks work with mat files?
이전 댓글 표시
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개)
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)
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
2019년 7월 5일
Star Strider
2019년 7월 5일
My pleasure.
In the absence of your ‘mytrace2131soma&syns.mat’ file, this will likely remain a mystery.
Nothing I can do to simulate what I believe could be wrong reproduces the problem you report. Even if the argument has no variation at all, findpeaks will produce a plot (if you call it without outputs):
findpeaks(ones(1, 90))
If you give it a cell array or a structure (it only accepts single or double precision vectors), it will throw an error. Since you did not report it throwing any errors, I have no idea what the problem could be.
Fran
2019년 7월 5일
Star Strider
2019년 7월 5일
That findpeaks call creates a horizontal line at 1 when I run it (without outputs) in R2019a.
Be sure your MATLAB version has all the latest updates. Click on Add-Ons in the top toolstrip, then scroll down to Check for Updates, then click on Products. I described this procedure in detail in: 2018b Update 3. The problem you’re having with findpeaks could be a bug that was later corrected in your version.
Upgrading to 2019a would definitely be a good idea. (Check for Updates moved to Help in R2019a.)
Fran
2019년 7월 5일
Star Strider
2019년 7월 5일
My pleasure!
Did you do the updates?
If so, did they solve your problem?
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.
카테고리
도움말 센터 및 File Exchange에서 Correlation and Convolution에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!