How to create subplots of findchangepts function?

Hello everyone,
I'm trying to plot several findchangepts plots as subplots in a single figure. I found it can't be done unfortunately.
Do you have any idea how to do so? any workaround?
Kindly check the attached .mat file. Here's what I need to plot.
subplot(3,1,1)
findchangepts(B,'MaxNumChanges',5);
subplot(3,1,2)
findchangepts(Bz,'MaxNumChanges',5);
subplot(3,1,3)
findchangepts(Dst,'MaxNumChanges',5);

 Respuesta aceptada

Sean de Wolski
Sean de Wolski el 24 de Dic. de 2019

1 voto

Take a look at the find change points live task which will generate the code for you for the plot you're looking for. Copy and paste it into subplot (or tiledlayout!)

6 comentarios

Mohamed Nedal
Mohamed Nedal el 24 de Dic. de 2019
I tried it but it shows each subplot separately. I need the 3 subplots in the same figure (one-by-one).
Untitled.png
Mohamed Nedal
Mohamed Nedal el 24 de Dic. de 2019
Editada: Mohamed Nedal el 24 de Dic. de 2019
I need the code to do like the following to apply it several times in a for loop.
I made this one manually, but it would be very time-consuming to make, let's say 1000 graphs.
Using my suggestion to copy the code from the live task and use it in your loop:
x = sin((1:3)'+(1:100));
t = tiledlayout(3,1);
for ii = 1:3
nexttile(t)
% Find change points
[changeIndices2,segmentMean] = ischange(x(ii,:));
% Display results
plot(x(ii,:),'Color',[109 185 226]/255,'DisplayName','Input data')
hold on
% Plot segments between change points
plot(segmentMean,'Color',[64 64 64]/255,'DisplayName','Segment mean')
% Plot change points
x2 = repelem(find(changeIndices2),3);
y = repmat([ylim(gca) NaN]',nnz(changeIndices2),1);
plot(x2,y,'Color',[51 160 44]/255,'LineWidth',1,'DisplayName','Change points')
title(['Number of change points: ' num2str(nnz(changeIndices2))])
end
cpts.png
Mohamed Nedal
Mohamed Nedal el 25 de Dic. de 2019
I'm getting this error.
Undefined function 'tiledlayout' for input arguments of type 'double'.
What would be the problem?
I also found no results for tiledlayout. My matlab version is R2017b.
Sean de Wolski
Sean de Wolski el 31 de Dic. de 2019
Tiledlayout was added in 19b. The same logic would work with subplot.
Mohamed Nedal
Mohamed Nedal el 31 de Dic. de 2019
I work on R2017b. I disabled these two lines t = tiledlayout(3,1); nexttile(t) And I wrote this line t = subplot (3,1,ii); Inside the for-loop, and it works :) Thank you!

Iniciar sesión para comentar.

Más respuestas (1)

Armin Iravani
Armin Iravani el 11 de En. de 2022
Editada: Armin Iravani el 11 de En. de 2022

0 votos

Hello,
the ischange function does not have two types of methods which findchangepts has such as 'rms' and 'std'. How to use subplot and findchangepts with these two methods?
thank you....

Productos

Versión

R2017b

Preguntada:

el 24 de Dic. de 2019

Editada:

el 11 de En. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by