Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab Matrix Multiplication Query in an fft application

  1. Apr 2, 2009 #1
    Hey everyone, first of all id just like to clarify this isnt a homework or coursework related problem, its part of my personal MatLab learning for future years. I obtained a nice little siganls and systems question off a friend, it looked fairly simple but ive come across a problem which i cant find a solution to. Here goes...

    Investigate the frequency content X(f) of a single 10 Hz sinewave, lasting for a time T_end. Set the sample frequency to be fs=1000, and T_end to be 2. Plot the absolute value of the function X(f) as a against frequency f.

    Here is my code for this part.

    function [x, t] = sinewave(T_end)
    fs = 1000;
    ts = 1/fs;
    T = T_end;
    t = 0:ts:T_end-ts;
    f= -fs/2 : 1/T : fs/2-1/T; % sets the frequecncy axis, between -500 and (500-0.5).
    x = sin(2.*pi.*f.*t);
    X = fft(x);
    Y = fftshift(X); % shifts right hand end to its alias below f=0, as graph is periodic this just centers the plot about 0.

    xlabel('frquency Hz');
    title('frequency content at T end = 2');

    I believe this to be correct, and can explain the results obtained at different T_end values.

    The next part of the question is where I get stuck.

    Replace the line that defines x(t) with the code,
    t1= 0:ts:1.0-ts;

    in order to create a pulse of length 1.

    When this code is entered i get the standard, Error using ==> times
    Matrix dimensions must agree.

    Error in ==> sinwav at 9

    I know this error occurs due to matrix multiplication, but simply .*'ing does not solve it,
    the matrix sizes are apparaently as follows, x[1 x 2000] , t1[1 x 1000], t[1x2000],f[1 x 2000]. And im not actually sure if i should add the .'s and this would change the outcome.

    Any comments or information would be greatly appericated, and hopefully this will help others as well.

    Many Thanks
    Last edited: Apr 2, 2009
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted

Similar Threads - Matlab Matrix Multiplication Date
Load Flow Order of Jacobian Matrix Power System Dec 29, 2017
Autocorrelation in Matlab Sep 24, 2017
Nyquist and FM and Signal Mixing... Aug 17, 2017
Electric field of AC source Jul 29, 2017
Matlab Derivative block analysis and filter design Jul 28, 2017