나는 matlab에 초보자이며 피크 아래에 계산 영역 문제가 있습니다. 다음은 봉우리를 찾기 위해 사용하는 코드입니다.matlab에서 trapz을 사용하여 피크 아래의 면적을 계산하는 방법은 무엇입니까?
%% Peak flow analysis 2 (Figure 3)
flowtable = finalCSVnew(:,[1,7:8]); % create table containing DateAndTime, Durchflusslm, and SummeaktuellerTagm data
peakflowEvent = flowtable{:,2} > aa ; % determine the threshold of flow(m3/h) for peakflowEvent
% use false as logical vector to determine transition. With function diff,
% transitions from false (0) to true (1) will be 1 and transitions from true
% to false will be -1. This will be 1 at the start of a dry period and -1 after the end
peakTransitions = diff([false; peakflowEvent; false]);
eventStarts = find(peakTransitions == 1);
eventEnds = find(peakTransitions == -1) -1;
% define the peak flow of each event through the flow data (peakflow) and
% the time when peak flow is happened (peakflowtime)
[peakflow, peakflowlocrel] = arrayfun(@(s, e) max(flowtable.Durchflusslm(s:e)), eventStarts, eventEnds);
peakflowlocabs = peakflowlocrel + eventStarts - 1;
peakflowtime=flowtable.DateAndTime(peakflowlocabs);
% create result table containing start and end time for peak flow event, the duration
% between start and end time, and peak flow
peakflowanalysis2 = table(flowtable.DateAndTime(eventStarts), flowtable.DateAndTime(eventEnds), ...
flowtable.DateAndTime(eventEnds) - flowtable.DateAndTime(eventStarts), ...
peakflow, peakflowtime, ...
'VariableNames', {'Start', 'End', 'Duration','PeakFlow','PeakFlowTime'});
numPeakflow2 = height(peakflowanalysis2); % calculate the number of max flow
% plot flow and peak flow
figure(3)
plot(flowtable.DateAndTime,flowtable.Durchflusslm,flowtable.DateAndTime(peakflowlocabs),peakflow,'v','MarkerFaceColor','red',...
'MarkerSize',5)
xlabel('Date and Time'); % define Date and Time as x-axis
ylabel('Flow [m3/h]'); % define Flow as y-axis
title('Peak Flow Events (2)'); % define the title of the plot
legend('Flow','Peak Flow','Location','Northeast','Orientation','Vertical')
grid on % show grid on plot
datacursormode on % enable to display data value interactively in the plot
% clear temporary variables
clearvars peakflowEvent peakTransitions eventStarts eventEnds peakflowlocrel peakflowlocabs peakflow peakflowtime
두 개의 테이블과 한 개의 그림을 생성합니다. 피크를 포함하고 각 이벤트를 나타내는 그림입니다. 가 이 아래 표가 피크가 필터링 된 데이터를 포함
나는 아래의 면적을 계산하는 방법을 알고 싶어 피크의 수는 표는 원래의 데이터를 포함 이벤트의 수를 = 각 이벤트의 피크 (11 개 이벤트)이며 모두를 합한 것이 아닙니다. 나는 trapz()에 대해 읽었지 만, 다중 봉우리에 적용하는 방법을 혼란스럽게합니다. 저 좀 도와 주 시겠어요? 당신의 도움을 주셔서 대단히 감사합니다.
답장을 보내 주셔서 감사합니다. 미안하지만 시작과 끝을 내 flowdata로 변환하는 것에 대해서는 아직 이해가되지 않습니다. 그것에 대해 더 자세히 설명해 주시겠습니까? –
Trapz는 벡터를 입력으로 요구합니다. 하나의 거대한 벡터 만 가지고 있기 때문에, 각 홍수 사건의 시작과 끝의 지표를 제공해야합니다. 시작과 끝 날짜 만 문자열로 보입니다. 심지어 시작과 끝이 벡터에서 indice를 찾아야합니다. 문자열과 함께 작동하지만 daten을 사용하고 문자열을 숫자 데이터로 변환 할 때보 다 느리게 진행됩니다. – Squeezie
내 코드를 편집했습니다. 어쩌면 지금은 더 분명합니다 – Squeezie