I have cyclic data as shown in the attached figure.
I amanged to define the minima and peak for each cylce
I would like to fit a regression for each cycle using Matlab. how can i do this?
this is what i have done so far:
%% data
close all
clear all
clc
data_org = importdata('N_trial.txt');
testname = sprintf('N_trial');
Time=data_org(:,1);
FV=data_org(:,2);
FH1=data_org(:,3);
FH2=data_org(:,4);
dV_raw=data_org(:,5);
dH1_raw=data_org(:,6);
dH2_raw=data_org(:,7);
ln = plot(Time, FV);set(ln, 'Color');
hold on
%input parameters
V_flex = 0.000001; %Vertical flexibility factor
H1_flex = 0.048; %Horizontal 1 flexibility factor
%calculate Displacement with correction of flexibility
dV_net = (dV_raw-V_flex*FV)*1000-85.64;
%% identify cycles
[pks,locs] = findpeaks(data_org(:,2),'MinPeakDistance',70);
% find minimum points(fatin)
FV_Inv = 1.01*max(FV) - FV
[Minima,MinIdx] = findpeaks(FV_Inv,'MinPeakDistance', 70);
Minima = FV(MinIdx);
%count_cycle= numel(findpeaks(your_signal))
count_cycle= numel(Minima);

답변 (1개)

KSSV
KSSV 2021년 8월 23일

0 개 추천

Read about polyfit. This will fit you striaght line/ curve for a given data (x,y).

카테고리

도움말 센터File Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

질문:

2021년 8월 22일

답변:

2021년 8월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by