How to let Matlab divide my data on time interval [0 400] into multiple time intervals in one plot [0 30] [30 60] etc.
16 ビュー (過去 30 日間)
古いコメントを表示
I have a code for Matlab to plot my data on time interval 0s to 400s. I now want Matlab to divide that time interval in pieces of 50s, but I want to initial plot to stay in tact.
So I still want to see this initial example plot, but with the outlier rejection lines for each time interval of 50 seconds. Hope my problem is clear.
Thanks in advance
2 件のコメント
Mathieu NOE
2023 年 5 月 30 日
if you could do it for an interval of 400s , what is the issue for intervals of 50 seconds ?
make a for loop and shift the start / stop index of your data by 50 samples at each iteration
採用された回答
Star Strider
2023 年 5 月 30 日
Fs = 259/50;
Tlen = 380;
t = linspace(0, Tlen*Fs, Tlen*Fs+1)/Fs;
f = 0.2;
s = sin(2*pi*t*f)*15-5 + randn(size(t))/10;
figure
plot(t, s)
grid
xlabel('Time')
ylabel('Amplitude')
bufsz = Fs*50;
tbuf = buffer(t, bufsz);
sbuf = buffer(s, bufsz);
figure
hold on
for k = 1:size(sbuf,2)
sbuf(sbuf(:,end)==0,end) = NaN;
plot(tbuf(:,k), sbuf(:,k))
end
hold off
xlabel('Time')
ylabel('Amplitude')
The calculations are straightforward, so I will let you explore them to understand how it works.
.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Whos についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!