フィルターのクリア

Creating new arrays under conditions.

3 ビュー (過去 30 日間)
Leon Ellis
Leon Ellis 2021 年 9 月 6 日
編集済み: Jan 2021 年 9 月 6 日
So what I want to do is the following: I have 2 vectors: Start() and stop() containing starting points of a signal and ending points of a signal. What I want to do is the following: If the absolute value of the difference between the ending point and next starting point is less than, say 1000, I want the new ending point to be the next one in the array.
So, given start = (5000 , 7000, 12500, 14200, 19000) and stop=(4500, 8520, 14000, 14500, 21000), The difference between the first and fourth column is less than 1000, so I want an array with the first new stop to be the 2'nd stop (8520) and the 4'th stop to be the fifth (21000), so: New_stop = (8520, 14000, 21000).
This is my code, but I keep getting an error. Help would be much appreciated and thanks in advance!
OriginalStart=start;
for j=1:length(start)
New_start(j)=start(j+1) (abs(stop(j)-start(j))<5000);
New_stop(j)=stop(j+1) (abs(stop(j)-New_start(j))<5000);
end

採用された回答

Jan
Jan 2021 年 9 月 6 日
編集済み: Jan 2021 年 9 月 6 日
start = [5000, 7000, 12500, 14200, 19000];
stop = [4500, 8520, 14000, 14500, 21000];
keep = (abs(start - stop) >= 1000);
newStop = stop(keep)
newStop = 1×3
8520 14000 21000
What is the wanted output for newStart?
newStart = start(keep) % ?
newStart = 1×3
7000 12500 19000
newStart = start([true, keep(1:end - 1)]) % ?
newStart = 1×3
5000 12500 14200

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by