I actually wanted the shifted plot to look like that below. With the blue plot being shifted to the green plot's position, then multiplying the green plot and red plot together to get the "Product" plot. I was not sure how to approach this issue and led you down the wrong path of implementing the circshift function. Sorry and Thanks for your help.
Shift data in the negative x direction then multiply shifted data with other plot
2 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I have two plots from a simulated loop. I wanted to shift the data in plot 2 in the negative x direction, then multiply the shifted data with plot 1. How can I go about doing that? I have attached my data file.
Here is the code that I have so far:
% Read the file and store into matrix v
v=csvread('data_1.csv');
% Frequency vector
freq1 = v(:,1);
plot1 = v(:,2);
freq2 = v(:,3);
plot2 = v(:,4);
freq2_shifted = freq2*.5;
semilogx(freq1,plot1);
ylim([-20 10]);
grid on;
hold on
semilogx(freq2,plot2);
semilogx(freq2_shifted,plot2);
legend('plot 1','plot 2','shifted');
hold off
2 件のコメント
採用された回答
Star Strider
2016 年 2 月 18 日
The circshift function would be my approach, but I don’t know what you intend by ‘shift’.
9 件のコメント
Star Strider
2016 年 2 月 19 日
My pleasure.
I am not certain how you shifted the frequencies, since you didn’t describe that. If you want to shift the data with respect to the frequencies, that would be easy: just do a circshift on the data, leaving the frequencies unshifted, then trim the last values from all records to eliminate the shifted value and last points from the other records. (An alternative would be to just trim the shifted data and then to use interp1 with the 'extrap' option to ‘create’ the missing shifted data. Your data are smooth enough to allow that.)
Or, you can shift the frequencies and keep the data unchanged. Your call.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!