Align multiple graphs in a plot

3 Ansichten (letzte 30 Tage)
Andreas Ingelström
Andreas Ingelström am 7 Jul. 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 Kommentar
Andreas Ingelström
Andreas Ingelström am 7 Jul. 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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Networks finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by