Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Matlab Matrix Multiplication Query in an fft application

Status
Not open for further replies.

1alph1

Newbie level 2
Joined
Mar 31, 2009
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,300
multiplication fft

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.

Code:
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.

stem(f,abs(Y),'k')
xlabel('frquency Hz');
ylabel('Abs(X)');
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,
Code:
t1= 0:ts:1.0-ts;
				x=0*t;
				x(1:length(t1))=sin(2*pi*f*t1);
				figure(1)
				plot(t,x)
				figure(2)

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
x(1:length(t1))=sin(2*pi*f*t1);

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.

Im not sure why the value for t is a 1 by 2000 matrix, im sure it should only be a 1000.

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

Many Thanks
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top