連続値の抽出
38 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
添付のようなCSVファイルがあります。
signal列において、NAを含むことなく数字が5回、10回連続する際の初めの#列の数値を抽出したいです。
例1:5回連続、#列 8
例2:10回連続、#列 25
0 commentaires
Réponse acceptée
Atsushi Ueno
le 3 Fév 2022
Modifié(e) : Atsushi Ueno
le 3 Fév 2022
mat = readmatrix('例題.csv')'; % 転置して読み込み
len = 0;
for k = ~isnan(mat(1,:))
len(end+1) = (len(end)+1)*k; % 連長圧縮の応用(lenはmatより1列長くなる事に注意)
end
mat(2, find(len==5,1)-5) % 例1:signal列において、NAを含むことなく数字が5回連続する際の初めの#列の数値
mat(2, find(len==10,1)-10) % 例2:signal列において、NAを含むことなく数字が10回連続する際の初めの#列の数値
[mat; len(2:end)] % 【参考】1行目:signal列の転置、2行目:#列の転置、3行目:連続する数値列の長さ
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur 線形予測符号化 dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!