Error using cppelt - findchangepts function

10 ビュー (過去 30 日間)
Emilia
Emilia 2022 年 4 月 17 日
回答済み: Star Strider 2022 年 4 月 17 日
Hello everyone,
I need to get the breakpoints of a time series. I coded
bp = findchangepts(data,'MaxNumChanges',2);
However I obtained
Error using cppelt
The input data type must be either single or double precision
Error in findchangepts>cpmulti (line 241)
[cpmax, minresidue] = cppelt(x, 0, Lmin, statistic);
Error in findchangepts (line 76)
[cp, residue] = cpmulti(x, statistic, Lmin, Kmax);
Apparently, the problem is 'MaxNumChanges',2, because if I skip it, I get a result (only 1 breakpoint). My data type is double precision, so I don't understand what happens
Somebody could help me, please?
Thanks a lot

回答 (1 件)

Star Strider
Star Strider 2022 年 4 月 17 日
Your findchangepts call works correctly when I test it here —
t = linspace(0, 10);
data = +(t>4.5); % The '+' Converts 'logical' To 'double'
bp = findchangepts(data,'MaxNumChanges',2)
bp = 46
figure
plot(t, data, t(bp), data(bp), 'pg', 'MarkerSize',11)
grid
ylim([-0.1 1.1])
whos t data
Name Size Bytes Class Attributes data 1x100 800 double t 1x100 800 double
Use whos to be certain that your data are single or double as findchangepts requires.
.

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by