필터 지우기
필터 지우기

How to let Matlab divide my data on time interval [0 400] into multiple time intervals in one plot [0 30] [30 60] etc.

조회 수: 6 (최근 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
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
Dustin
Dustin 2023년 5월 30일
편집: Dustin 2023년 5월 30일
I am a beginner and I did not write the code myself. I have to change it for my schoolproject.
I know some basics, but I don't know how to make this: make a for loop and shift the start / stop index of your data by 50 samples at each iteration. Can you help me write that code?
I have two vectors: time 1x1978
value 1x1978
Each 50 seconds has 259 datapoints.

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2023년 5월 30일
If you have the Signal Processing Toolbox, use the buffer function and a loop —
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')
You can also use reshape, although buffer is easier.
The calculations are straightforward, so I will let you explore them to understand how it works.
.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by