Add increasing values within an array
古いコメントを表示
Hello, I have the following problem:
I get data of the angle of rotation of a screwdriver. Within a screw joint, the angle of rotation is reset to zero at a point in time. This can happen any number of times during a pass. Example:
1°,5°,10°,12°,1°,5°,10°,12°,1°,5°,10°,12°. The numbers are only exemplary.
I would like to merge the values now to a continuous data series. At the moment I have this code:
I hope I was able to describe the problem understandably. Many thanks
clear;
w=[1;2;3;1;2;3;1;2;3]; % Example Data
W=[];
for n=1:1:length(w)
if n==1
W(n)= 0; % 0 corresponds to: angle not reset
elseif n==max(length(w))
W(n)= 0;
elseif w(n)== w(n+1)
W(n)=0;
elseif w(n)>w(n-1)
W(n)=0;
elseif abs(w(n)-w(n-1))<-2
W(n)=0
elseif w(n)<w(n-1) % 1 corresponds to: Angle reset
W(n)=1;
end
end
4 件のコメント
KALYAN ACHARJYA
2022 年 10 月 28 日
What would be expected output in this case w=[1;2;3;1;2;3;1;2;3]; example?
Star Strider
2022 年 10 月 28 日
Please describe the desired output for a specific input, and any rules that might govern getting that output.
Ole Braunholz
2022 年 10 月 28 日
Star Strider
2022 年 10 月 28 日
I still do not understand.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Chemistry についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!