필터 지우기
필터 지우기

Plotting the same signal with a different scanning

조회 수: 3 (최근 30일)
Philipp Mueller
Philipp Mueller 2021년 5월 27일
편집: EmirBeg 2021년 5월 27일
Hello,
One time i measure a signal for 30 seconds with 50 Hertz and the second time i measure the same signal 30 seconds now with 600 Hertz. So i get 2 arrays (x*2 double) with a different size. Now i want to plot this 2 signals in one diagram. Is this possible?

채택된 답변

EmirBeg
EmirBeg 2021년 5월 27일
편집: EmirBeg 2021년 5월 27일
You can interpolate one of the signals to make them the same size. Something like this:
Signal1 = (linspace(1,30,30))';
Signal2 = (linspace(1,30,180))'; %don't mind this, just creating your signals with different frequencys
Signal1_int = interp1(1:size(Signal1,1),Signal1.',linspace(1,size(Signal1,1),size(Signal2,1)))';
%interpolating the first signal so it's the same size as the second
Now you can plot both signals in one plot.
plot(t,Signal1_int,t,Signal2);
Or just use hold on and hold off.

추가 답변 (1개)

Asmit Singh
Asmit Singh 2021년 5월 27일
If I understood correctly, you are trying to plot 2 signals in a single graph. This documentation should be helpful. You can plot 2 signals in a single graphs using 'hold on'.
x = linspace(-pi,pi);
y1 = sin(x);
plot(x,y1)
hold on
y2 = cos(x);
plot(x,y2)
hold off
  댓글 수: 1
EmirBeg
EmirBeg 2021년 5월 27일
can't do it if the arrays aren't the same size.

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by