필터 지우기
필터 지우기

Trouble using findpeaks function

조회 수: 7 (최근 30일)
Snow
Snow 2023년 7월 8일
답변: Star Strider 2023년 7월 8일
The attached data is a sinusodial wave. I want to find how many peaks are in this graph. In matlab, I click on the file and import thata data from both columns. I get the following error:
Error using findpeaks
Expected Y to be one of these types:
double, single
Instead its type was table.
Error in findpeaks>parse_inputs (line 199)
validateattributes(Yin,{'double','single'},{'nonempty','real','vector'},...
Error in findpeaks (line 135)
= parse_inputs(isInMATLAB,Yin,varargin{:});
So importing the data that way makes it a table.
Ok so i make a variable for each column and turned them into a 5464x1 matrix.
Im not sure what to do next in order to analyze the peaks. ANy help?

답변 (1개)

Star Strider
Star Strider 2023년 7월 8일
I have no idea how you are importing them. The findpeaks function wants real vector data.
Try something like this —
T1 = readtable('run 4 vac to air volt.csv', 'VariableNamingRule','preserve')
T1 = 5464×2 table
Voltage, Ch A (V) Run #4 Voltage, Ch B (V) Run #4 ________________________ ________________________ -0.218 -9.412 -0.218 -9.413 -0.218 -9.413 -0.218 -9.412 -0.218 -9.412 -0.218 -9.413 -0.218 -9.413 -0.218 -9.413 -0.218 -9.412 -0.218 -9.413 -0.219 -9.413 -0.219 -9.413 -0.219 -9.413 -0.219 -9.413 -0.218 -9.412 -0.219 -9.413
ChA = T1{:,1};
ChB = T1{:,2};
[pksA,locsA] = findpeaks(ChA, 'MinPeakProminence',0.01);
[pksB,locsB] = findpeaks(ChB, 'MinPeakProminence',0.01);
figure
subplot(2,1,1)
plot(ChA)
hold on
plot(locsA,pksA, '+r')
hold off
hold on
hold off
subplot(2,1,2)
plot(ChB)
hold on
plot(locsB,pksB, '+r')
hold off
Note the use of curly braces {} to index into the table array.
Make appropriate changes to get the results you want.
.

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by