Does findpeaks work with mat files?
Mostrar comentarios más antiguos
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!
Respuestas (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)
1 comentario
Fran
el 5 de Jul. de 2019
Star Strider
el 5 de Jul. de 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 comentarios
Fran
el 5 de Jul. de 2019
Star Strider
el 5 de Jul. de 2019
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
el 5 de Jul. de 2019
Star Strider
el 5 de Jul. de 2019
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
el 5 de Jul. de 2019
Star Strider
el 5 de Jul. de 2019
My pleasure!
Did you do the updates?
If so, did they solve your problem?
Star Strider
el 6 de Jul. de 2019
Please do!
I have no idea what the problem with findpeaks is in your R2017 installation. I never had any problems with it.
Categorías
Más información sobre Multirate Signal Processing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!