Error using cppelt - findchangepts function

9 visualizzazioni (ultimi 30 giorni)
Emilia
Emilia il 17 Apr 2022
Risposto: Star Strider il 17 Apr 2022
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

Risposte (1)

Star Strider
Star Strider il 17 Apr 2022
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.
.

Community Treasure Hunt

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

Start Hunting!

Translated by