Using FInd Peak function but not getting required values
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Using my custom find_peak function to locate the highest maximum and lowest minimum values in three Phases. But in last Phase I am not getting the required output even calling all phase with a same function. Secondly getting the 50% decay values that are negative. Kindly guide me what is wrong in my code. I am sharing my script and GUI file and screenshot
0 Kommentare
Antworten (1)
Nipun
am 14 Jun. 2024
Hi Ehtisham,
I understand that you are having issues with the findpeaks function to locate the highest maximum and lowest minimum values in three phases, and you are encountering problems in the last phase and with 50% decay values. I recommend the following steps to get the expected results:
Highest Maximum and Lowest Minimum Values: Ensure you are correctly identifying peaks and troughs for each phase.
[~, locsMax] = findpeaks(signal, 'MinPeakHeight', threshold);
[~, locsMin] = findpeaks(-signal, 'MinPeakHeight', threshold);
maxValue = max(signal(locsMax));
minValue = min(signal(locsMin));
Handling Multiple Phases: Loop through each phase and apply the findpeaks function.
for phase = 1:numPhases
currentSignal = phases{phase}; % Assuming phases is a cell array of signals
[~, locsMax] = findpeaks(currentSignal, 'MinPeakHeight', threshold);
[~, locsMin] = findpeaks(-currentSignal, 'MinPeakHeight', threshold);
maxValue = max(currentSignal(locsMax));
minValue = min(currentSignal(locsMin));
disp(['Phase ', num2str(phase), ': Max = ', num2str(maxValue), ', Min = ', num2str(minValue)]);
end
50% Decay Values: Ensure you are computing the decay values correctly. If values are negative, adjust your computation accordingly.
halfDecayValue = 0.5 * maxValue; % Assuming maxValue is positive
decayLocs = find(signal <= halfDecayValue, 1);
if isempty(decayLocs)
disp('No decay point found');
else
decayValue = signal(decayLocs);
disp(['Decay value: ', num2str(decayValue)]);
end
Make sure to verify the phase-specific signals and their thresholds. This should help you identify why the last phase behaves differently.
Hope this helps.
Nipun
1 Kommentar
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!