Align multiple graphs in a plot

2 次查看(过去 30 天)
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 个评论
Andreas Ingelström
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Networks 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by