How to store all FOR loop iteration in a vector and plot every iteration?
3 ビュー (過去 30 日間)
古いコメントを表示
I want to save the data of every iteration in a vector, and plot it later . Could anyone give me a hint on how to do this ?
for a=1:114
power=pote(a,:);
mean_power_50=filter(ones(1,50)/50,1,power);
power_fading=power-mean_power_50;
x1=power_fading(1:1000);
x2=power_fading(1001:2001);
x3=power_fading(2002:3002);
x4=power_fading(3003:4003);
x5=power_fading(4004:5000);
end
0 件のコメント
採用された回答
Guillaume
2016 年 10 月 11 日
The loop is not needed at all, filter can operate on the column of whole matrices at once. However, since you're working on rows, you'll have to transpose your matrix (and transpose the result):
mean_power_50 = filter(ones(1,50)/50,1, pote.').'; %work on the whole array
power_fading = pote - mean_power_50;
You can then split it into subarrays. However do not use numbered variables. Instead put these subarrays altogether into a cell array or other container:
%assuming that power_fading is 5000 columns:
x = mat2cell(power_fading, size(power_fading, 1), [1000 1001 1001 1001 997]); %any reason why it's not 1000 for each submatrix?
9 件のコメント
Guillaume
2016 年 10 月 13 日
The error tells you that it's running out memory when computing the inverse fourier transform during your cross correlation. This would be caused by the matrix passed to xcorr having too many columns, which may be due to a mistake I made.
If your signals are arranged by rows, then the matrix needs to be transposed before passing it to xcorr, so if you change the toplot line to:
toplot = xcorr(power_split{idx}.', 'coeff');
does it work better?
Unfortunately, I don't have the signal processing toolbox nor matlab coder so I can't really test the answer I gave you.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!