フィルターのクリア

How to select thresholds on a XY plot and fit a line btw thresholds

6 ビュー (過去 30 日間)
Alessandro Garofolini
Alessandro Garofolini 2018 年 8 月 27 日
回答済み: Nawaf Almutairi 2018 年 8 月 27 日
Hi there, I have a matrix (test & test1) of vectors that I split into a matrix of X (ANG) values and a matrix of Y (MOM) values. I am plotting XY in a scatter plot. I then want to identify when the slope of the XY plot is changing. Those points will be the thresholds I need.
I want the code to be able to identify thresholds in both cases. This is what I have done:
%%Identify index for 5% and 95% MOM using threshold
Mom5up_indx=zeros(1,length(MOM));
Mom95up_indx=zeros(1,length(MOM));
Mom5down_indx=zeros(1,length(MOM));
Mom95down_indx=zeros(1,length(MOM));
for i=1:length(Mom5)
Mom5up_indx(1,i)= find(MOM(:,i)>=Mom5(1,i),1,'first');
Mom95up_indx(1,i)= find(MOM(:,i)>=Mom95(1,i),1,'first');
Mom5down_indx(1,i)= find(MOM(:,i)>=Mom5(1,i),1,'last');
Mom95down_indx(1,i)= find(MOM(:,i)>=Mom95(1,i),1,'last');
end
%%Identify Linear fit and Slope value for the three segments of the ANG-MOM signal
%Define thresholds
THR1= Mom5up_indx; % First crossing 5% of Max MOM
THR2= ??; % First change in Slope after 5% of Max MoM
THR3= ??; % Second change in Slope after 5% of Max MoM
THR4= Mom95up_indx; % First crossing 95% of Max MOM
THR5= Mom95down_indx; % Last before crossing 95% of Max MOM
THR6= Mom5down_indx; % Last before crossing 5% of Max MOM
% Preallocation of variables
Slope1=zeros(1,length(ANG));
Slope2=zeros(1,length(ANG));
Slope3=zeros(1,length(ANG));
for i=1:length(ANG)
f= fit(ANG([THR1(i):THR2(i)],i),MOM([THR1(i):THR2(i)],i),'poly1');
Slope1(1,i) = f.p1(1);
f1= fit(ANG([THR3(i):THR4(i)],i),MOM([THR3(i):THR4(i)],i),'poly1');
Slope2(1,i) = f1.p1(1);
f2= fit(ANG([THR5(i):THR6(i)],i),MOM([THR5(i):THR6(i)],i),'poly1');
Slope3(1,i) = f2.p1(1);
end
Hope you have all the info you need to help me. Many thanks
Ale
  2 件のコメント
dpb
dpb 2018 年 8 月 27 日
Instead of (or in addition too) attaching .fig files, how about saving as .jpg and inserting images so folks can see w/o downloading?
Alessandro Garofolini
Alessandro Garofolini 2018 年 8 月 27 日
Thanks dpb! good suggestion ;)
Ale

サインインしてコメントする。

回答 (1 件)

Nawaf Almutairi
Nawaf Almutairi 2018 年 8 月 27 日
hud

カテゴリ

Help Center および File ExchangeParticle & Nuclear Physics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by