If I want to choose one cycle. The cycle must have criteria : largest distance maximum & minimum, 3 point cross X axis. Thank you very much in advanced.

댓글 수: 1

Turlough Hughes
Turlough Hughes 2020년 3월 11일
편집: Turlough Hughes 2020년 3월 11일
What do you mean by one cycle? Are you looking for the maximum change in y given a change in x of 3?

댓글을 달려면 로그인하십시오.

 채택된 답변

Image Analyst
Image Analyst 2020년 3월 11일

1 개 추천

This will do it:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
s = load('data.mat')
data = s.data;
hFig = figure;
plot(data, 'b-', 'LineWidth', 2)
grid on;
xlabel('Index', 'FontSize', fontSize);
ylabel('Signal', 'FontSize', fontSize);
% Maximizxe the window.
hFig.WindowState = 'maximized';
% Find the max
[maxValue, indexOfMax] = max(data)
% Find the min
[minValue, indexOfMin] = min(data)
% Find out where the signal last crosses 0 before the peak
% First set after the peak to infinity so we do not find that.
tempSignal = data;
tempSignal(indexOfMax:end) = inf;
indexLeft = find(tempSignal < 0, 1, 'last')
% Plot a red spot there.
hold on;
plot(indexLeft, data(indexLeft), 'r.', 'MarkerSize', 40);
% Find out where the signal first crosses 0 after the max peak on the right side.
% First set before the valley to infinity so we do not find the peak.
tempSignal = data;
tempSignal(1 : indexOfMax) = inf;
indexMiddle = find(tempSignal < 0, 1, 'first')
% Plot a red spot there.
hold on;
plot(indexMiddle, data(indexMiddle), 'r.', 'MarkerSize', 40);
% Find out where the signal first crosses 0 after the min peak (the biggest valley).
% First set before the valley to -infinity so we do not find the peak.
tempSignal = data;
tempSignal(1 : indexOfMin) = -inf;
indexRight = find(tempSignal > 0, 1, 'first')
% Plot a red spot there.
hold on;
plot(indexRight, data(indexRight), 'r.', 'MarkerSize', 40);

댓글 수: 4

Arief Kus
Arief Kus 2020년 3월 11일
Thank you very much for your help.
Image Analyst
Image Analyst 2020년 3월 11일
You're welcome. Can you "Accept this answer" now by clicking the link?
Arief Kus
Arief Kus 2020년 3월 18일
Done. I am really sorry for late in clicking "Accept this answer".
Arief Kus
Arief Kus 2020년 3월 18일
If I have X and Y data. I want to choose one cycle. The cycle must have criteria : largest distance maximum & minimum, 3 point cross X axis.Thank you very much in advance.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 White에 대해 자세히 알아보기

제품

태그

질문:

2020년 3월 11일

댓글:

2020년 3월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by