How can I get curving points of trapezoid shape in 1d array
2 ビュー (過去 30 日間)
古いコメントを表示
I have 1d array with 65600 elements. I extract them from excel file -"data.xlsx".
data=[ 2,223351 2,224009 2,224009 2,224009 2,223351 2,224666 2,224009 2,223351 2,224009 2,224666 .......
2,224666 2,223351 2,225324 2,223351 2,225324 2,225324 2,225982 2,228613 2,229928 2,233874 .......
17,388309 17,390282 17,390940 17,390940 17,392913 17,392255 17,393571 17,394886 17,398832 17,397517 ......
17,397517 17,396201 17,398832 17,397517 17,398174 17,397517 17,397517 17,398832 17,397517 17,397517 ......
17,392255 17,392913 17,390940 17,392255 17,392913 17,392255 17,392255 17,392255 17,394228 17,389624 ......
1,499894 1,503840 1,497921 1,498579 1,498579 1,497263 1,497263 1,497921 1,496605 1,495290 ......
1,494632 1,493975 1,491344 1,492002 1,492002 1,492002 1,491344 1,492002 1,492659 1,492002 ......]
When I plot them , I have following graph:
My task is how to detect 4 curving points (elements of the array) which are circled. The problem here is high populated repetitive elements.
I tried following algorithm.
Loop Getting similarity percentage of two consequetive segments comprising 10 elements each unless I get 0%, return last element of segment.
function curvepoint1=SegmentProcess2(arr) % Function for array processing
len=round(length(arr)/10) % devide array into segments with 10 elements each
for i=1:len
if i==1
segment1=arr(1:9);
segment2=arr(10:19);
else
j=10*i;
k=j+9;
segment1=arr(j:k);
segment2=arr(k+1:k+10);
end
persentage=SimilarF(segment1,segment2);
if persentage==0
%res_seg=segment1;
a=i;
break
end
end
curvepoint1=a*10;
end
function [maxP, maxPos]=SimilarF(arr1,arr2)
x=arr1.';
y=arr2.';
nx=length(x);
ny=length(y);
yy=[y, nan(1,nx-1)];
p=ones(1,ny);
for iy=1:ny
p(iy)=find([(yy(iy:iy+nx-1)~=x),true],1)-1;
end
maxP=max(100*p/nx);
end
0 件のコメント
採用された回答
darova
2019 年 5 月 5 日
I reduced points and find search for angle difference bigger than
clc, clear, cla
load data.txt
tol = 500;
t = 1:tol:length(data); % reducing points
y = data(t);
plot(t,y,'.-b')
hold on
k = 0.5; % play with this
ind = find(abs(diff(y,2)) > k); % find angle change bigger than
ind = ind + 1;
plot(t(ind),y(ind),'or')
hold off
And what i've got
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Statistics and Machine Learning Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!