Results 1 to 4 of 4

Math Help - MATLAB: Plotting MATRIX?

  1. #1
    Newbie
    Joined
    Nov 2006
    Posts
    10

    MATLAB: Plotting MATRIX?

    How would I plot Q in this? I keep getting an error.


    Code:
    [x,fs,k]=wavread('sound0.wav'); 
    x = x(1:length(x),1);
    N=length(x);
    time=[0:1:N-1]*1/fs; 
    
    
    dead=zeros(fs,1); 
    x1=[x;dead;dead;dead]; 
    x2=0.7*[dead;x;dead;dead];
    x3=(.5)*[dead;dead;x;dead];
    x4=(.3)*[dead;dead;dead;x];
    
    
    q=x1+x2+x3+x4;
    %sound(q,fs);
    plot(time,q);
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Member
    Joined
    May 2006
    Posts
    244
    Quote Originally Posted by synnexster View Post
    How would I plot Q in this? I keep getting an error.


    Code:
    [x,fs,k]=wavread('sound0.wav'); 
    x = x(1:length(x),1);
    N=length(x);
    time=[0:1:N-1]*1/fs; 
     
     
    dead=zeros(fs,1); 
    x1=[x;dead;dead;dead]; 
    x2=0.7*[dead;x;dead;dead];
    x3=(.5)*[dead;dead;x;dead];
    x4=(.3)*[dead;dead;dead;x];
     
     
    q=x1+x2+x3+x4;
    %sound(q,fs);
    plot(time,q);
    Why are dead and x of the same length?

    Also if you want help finding the error in future tell us what the error message is, and at what point in the script that it occurs.

    .
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Nov 2006
    Posts
    10
    It happens at the plot(time,q); line.

    Here is the error:

    ??? Error using ==> plot
    Vectors must be the same lengths.

    dead adds 1 second of silence, and i've added echos: x1,x2,x3,x4. I just want to plot it.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Member
    Joined
    May 2006
    Posts
    244
    Quote Originally Posted by synnexster View Post
    It happens at the plot(time,q); line.

    Here is the error:

    ??? Error using ==> plot
    Vectors must be the same lengths.

    dead adds 1 second of silence, and i've added echos: x1,x2,x3,x4. I just want to plot it.
    You have not extended time in the same way you have extended q.

    Learn to use the debugger and single step through the script querying the size of the arrays as you go.

    .
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. loops in matlab, plotting matrix elements
    Posted in the Math Software Forum
    Replies: 1
    Last Post: April 10th 2011, 10:50 AM
  2. matlab plotting graph need help
    Posted in the Math Software Forum
    Replies: 1
    Last Post: August 7th 2010, 12:27 AM
  3. plotting a graph in matlab
    Posted in the Math Software Forum
    Replies: 3
    Last Post: March 21st 2009, 03:11 PM
  4. Matlab - Plotting Circles
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 16th 2009, 09:28 AM
  5. MATLAB - plotting a quadratic
    Posted in the Math Software Forum
    Replies: 2
    Last Post: June 15th 2008, 06:25 PM

Search Tags


/mathhelpforum @mathhelpforum