Separating of succecive monotonic vectors

1 visualización (últimos 30 días)
moncef soualhi
moncef soualhi el 9 de Sept. de 2019
Comentada: moncef soualhi el 10 de Sept. de 2019
Hi every one,
I have a vector which contains values. These values consist of several monotonic vectors (as show in the figure). For this purpuse, i'd like to extract each monotone vector alone. Is there a solution to be able to isolate each monotone vector from the global one?
Thank you for your attention and tyour help
  2 comentarios
the cyclist
the cyclist el 9 de Sept. de 2019
Could you also upload the original data from which you made that plot, in a MAT file?
moncef soualhi
moncef soualhi el 9 de Sept. de 2019
Hi, yes with pleasure. Please find in attachment the .mat file data.
Thank you very much for your help

Iniciar sesión para comentar.

Respuesta aceptada

Fabio Freschi
Fabio Freschi el 9 de Sept. de 2019
Let's assume your data are stored in x and y vectors. I take them from your picture
% get the data from picture
fig = gcf;
axObjs = fig.Children
dataObjs = axObjs.Children
x = dataObjs(1).XData;
y = dataObjs(1).YData;
your data are noisy. Let's specify a suitable threshold
threshold = 200;
the "negative jumps can be identified using diff
idx = [0 find(diff(y) < -threshold) length(y)];
the chunks of monotonical data have different sizes, I load them into a cell array
X = arrayfun(@(i)x(idx(i)+1:idx(i+1)),1:length(idx)-1,'UniformOutput',false);
Y = arrayfun(@(i)y(idx(i)+1:idx(i+1)),1:length(idx)-1,'UniformOutput',false);
Graphical check
figure, hold on
for i = 1:length(Y)
plot(X{i},Y{i})
end
  3 comentarios
Fabio Freschi
Fabio Freschi el 9 de Sept. de 2019
diff(y) < -threshold is a logical vector idx that contains the indices in the data vector where the jump is larger than the thrashold. With find we get the indices values. I added a leading 0 and a trailing 7538 (vector length) for the successive processing.
arrayfun is a nice matlab function. Have a look at the documentation for details. In this case that mimics in one row the following for loop
for i = 1:length(idx)-1
Y{i} = y(idx(i)+1:idx(i+1));
end
It loads in the ith cell of Y the monotonic portion of the vector y with starting index idx(i)+1 and final index idx(i+1)
moncef soualhi
moncef soualhi el 10 de Sept. de 2019
Thank you, it's very help full

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by