Align multiple graphs in a plot

3 visualizzazioni (ultimi 30 giorni)
Andreas Ingelström
Andreas Ingelström il 7 Lug 2016
Hi,
In my GUI I plot multiple graphs in one figure from a matrix (p_matrix) using a for loop. I need to align all the graphs (there are 52 of them) with one maximum point as the reference point, i.e. if I take the index of the maximum of the middle row of my matrix all the other rows maximum points should be at the same index. In some way I need to write a function that takes away some values from either the end or the beginning of the row depending on the maximum point of the row being at a lower or higher index respectively. I have tried with this attempt:
function [p_lined_graphs] = lineGraphs(p_matrix, y_matrix)
%Function to line up the graphs in order to take a mean value of them later
%and reducing the noise
p_lined_graphs = zeros(52,120);
for n=1:52
vector = p_matrix(n,:);
[maxValueN indexAtMaxN] = max(vector);
for m=10:110
if indexAtMaxN ~= indexAtMax
diffIndex = indexAtMax - indexAtMaxN;
p_lined_graphs(n,m) = p_matrix(n,abs(m-diffIndex));
elseif indexAtMaxN == indexAtMax
p_lined_graphs(n,m) = p_matrix(n,m);
end
end
end
, and then I plot the p_lined_graphs in my GUI code but the graphs aren't aligned... Is there anyone that might know what I have done wrong or have another simpler way of aligning the graphs?
Thanks in advance!
  1 Commento
Andreas Ingelström
Andreas Ingelström il 7 Lug 2016
An alternative could be to use the first value being bigger than 20 in the middle row to be the reference point and from that adjust the other rows.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Networks in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by