Shifting a graph without altering the data itself.
古いコメントを表示
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);
回答 (1 件)
Star Strider
2016 年 12 月 22 日
0 投票
6 件のコメント
Yuval
2016 年 12 月 22 日
Star Strider
2016 年 12 月 22 日
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
2016 年 12 月 22 日
Star Strider
2016 年 12 月 22 日
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
2016 年 12 月 22 日
Star Strider
2016 年 12 月 22 日
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.
カテゴリ
ヘルプ センター および File Exchange で Transforms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!