plot

7 views (last 30 days)
Padma
Padma on 1 Nov 2011
[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

Answers (1)

Honglei Chen
Honglei Chen on 1 Nov 2011
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 Comments
Honglei Chen
Honglei Chen on 1 Nov 2011
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 on 1 Nov 2011
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));

Sign in to comment.

Categories

Find more on Geographic Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!