Issues with findpeaks()
26 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Joshua Walters
el 28 de Abr. de 2020
Comentada: ME
el 28 de Abr. de 2020
I'm having issues with using findpeaks() for lab data.
I have my script calling a csv file with 2 columbs of data.
As you can see from my script I can get the data to plot easily, however when I insert findpeaks(col1,col2) or findpeaks(data) I get an error message I don't understand.
The error I get is as follows:
----
Error using findpeaks
Expected Y to be a vector.
Error in findpeaks>parse_inputs (line 199)
validateattributes(Yin,{'double','single'},{'nonempty','real','vector'},...
Error in findpeaks (line 136)
= parse_inputs(isInMATLAB,Yin,varargin{:});
---
Can anyone please explaene to me why this isn't working.
clear all;
clc;
%Lab 2 Signoff 3
data=importdata("Light-Lab2.csv");
col1 = data(:,1);
col2 = data(:,2);
plot(col1,col2)
grid on, grid minor
title('lab2 data')
xlabel("Time")
ylabel("voltage")
findpeaks(data)
%findpeaks(col1,col2)
Respuesta aceptada
ME
el 28 de Abr. de 2020
I must stress that I am not sure and I don't have acces to the Signal Processing Toolbox to check. However, have you tried reversing the order of col1, col2 in your find peaks command?
I think that command is asking it to output the x-axis locations of the peaks in your y-axis data. This would be done as findpeaks(data,x). Therefore your x-data needs to be the second input argument and at present I think they are the wrong way around.
I think the issue when you try findpeaks(data) is that you aren't feeding in a vector (1xN) but rather an array (2xN).
I hope that helps!
5 comentarios
ME
el 28 de Abr. de 2020
No problem, apologies I couldn’t be more help. Without access to the toolbox I couldn’t test anything out.
Anyway, if this helped you would you possibly consider accepting my answer?
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!