Shifting a graph without altering the data itself.
Mostrar comentarios más antiguos
Hi, I have the following graph in which I'd like the two curves to coincide as closely as possible. Is there a way to achieve that without altering the data? Also, simply shifting the x data within the plot function by a certain offset (i.e. plot(x+offset,y)) doesn't yield the desired result.

Below is the plotting:
figure
subplot(2,1,1)
plot(k,RCS_PO,'k',k,RCS_MOM_soft,'m',k,RCS_MIE_soft,'b','LineWidth',2);
Respuestas (1)
Star Strider
el 22 de Dic. de 2016
0 votos
6 comentarios
Yuval
el 22 de Dic. de 2016
Star Strider
el 22 de Dic. de 2016
It requires a bit more than that:
x = linspace(0, 4*pi);
y1 = sin(x);
y2 = cos(x);
[y1a,y2a] = alignsignals(y2, y1); % Note Order of Arguments
xa = linspace(0, 4*pi*length(y1a)/length(y1), length(y1a)); % New Independent Variable For Aligned Signal
figure(1)
subplot(2,1,1)
plot(x, y1, '-b', x, y2, '-.r')
grid
subplot(2,1,2)
plot(xa, y1a, '-b', x, y2a, '-.r')
grid
Experiment with this code snippet, and with your signals to get the result you want.
Yuval
el 22 de Dic. de 2016
Star Strider
el 22 de Dic. de 2016
I don’t know what’s wrong.
Experiment with changing the order of the arguments to alignsignals. In my experiments with it, it aligns the first argument to match the second argument.
It may not be possible to align your signals exactly. Looking at the zero-crossings, they don’t appear to have the same frequencies and phase relationships.
Yuval
el 22 de Dic. de 2016
Star Strider
el 22 de Dic. de 2016
For that, I would choose a subset of your data (for example 4 to 8 ka) and use the delay calculated from that. You would insert a zero or NaN vector the length of the delay returned as the third argument of alignsignals to your signal vector, and use linspace to extend your independent (probably time) vector to the appropriate length.
Categorías
Más información sobre Transforms en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!