fitting different regressions for cyclic data
Show older comments
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);
Answers (1)
KSSV
on 23 Aug 2021
0 votes
Read about polyfit. This will fit you striaght line/ curve for a given data (x,y).
Categories
Find more on Linear and Nonlinear Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!