필터 지우기
필터 지우기

plot

조회 수: 2 (최근 30일)
Padma
Padma 2011년 11월 1일
[FileName,PathName] = uigetfile('padma_orignl.wav');
>> PathOriginal=sprintf('%s%s',PathName,FileName);
>> [xt,fs]=wavread(PathOriginal);
>> [FileName,PathName] = uigetfile('padma_delay.wav');
>> PathOriginal1=sprintf('%s%s',PathName,FileName);
>> [yt,fs]=wavread(PathOriginal1);
>> t=0:1/30897:1;
>> plot(t,xt,t,yt)
Error using plot
Vectors must be the same lengths.
When i have recorded two sample wav files, one with no delay and other with delay, obviously there would be some difference in length. Could you please tell me how i could overcome this error?
Thanks in advance Padma

답변 (1개)

Honglei Chen
Honglei Chen 2011년 11월 1일
There are several things you can do, the simplest is probably
plot(t,xt(1:length(t)),t,yt(1:length(t)))
This assumes that your data is at least as long as t, otherwise you'll have to truncate your t.
If you want to go a little further, you can do
t1 = 0:1/30897:length(xt);
t2 = 0:1/30897:length(yt);
plot(t1,xt,t2,yt)
HTH
  댓글 수: 2
Honglei Chen
Honglei Chen 2011년 11월 1일
I just fix a typo in my original post, I typed 20897 for t2 instead of 30897. You mention that your computer freezes and that might be because your xt and yt are too long. You could try something simple to make sure it works first, e.g.,
N = 1000; plot(t1(1:N),xt(1:N),t2(1:N),yt(1:N))
Honglei Chen
Honglei Chen 2011년 11월 1일
Hi Padma, Please add your comment here so other people can contribute too. To get comparable magnitude, you can try to normalize them, e.g.,
N = 1000; plot(t1(1:N),xt(1:N)/max(abs(xt)),t2(1:N),yt(1:N)/max(abs(yt)))
I'm not sure why your computer freezes when you set N = 10000, it is not a lot of data to plot. Maybe you can only create t for the points you with to plot? e.g.,
N = 10000; t = (0:N-1)/30897; plot(t,xt(1:N),t,yt(1:N));

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by