Need help in creating a script without using for loops.

I am trying to write a scrpt without using for loops. Attach is the scripts with for loops. They are for Q3a and Q3b.

4 commentaires

Home Work......what have you attempted?
it's hw. this is what I am trying to do.
Don't show your image as a image snippet....copy your code here.
%Biosensor Project 2 Q3
%Develop a function in MatLab to
%Calculate the Discrete Fourier Transform
%Check the function with the function in Matlab.
%Develop a function. Don't use loop.
%Implement function with matrices.
%To test function using following signals.
%a)Aperiodic signal
%x[n]={0,1,2,3,4,3,2,1,0,0,0,0}
x=[0 1 2 3 4 3 2 1 0 0 ]
l=length(x)
disp('array initialized with zero and length l')
for k=1:10
xk(k)=0;
for n=1:10
xk(k)=xk(k)+x(n)*k;
end
end
disp('displaying final transform')
disp(xk)
%function [Xk] = dft(xn)
%x=[0 1 2 3 4 3 2 1 0 0 ]
%len = length(xn);
%w = 2*pi*linspace(0,1-1/len,len);
%Xk = exp(-1j*w'*(n-1))*xn';

Connectez-vous pour commenter.

Réponses (1)

N=length(x);
Xk=sum(x.*exp((-1i*2*pi/N*(0:N-1)).*(0:N-1)'),2);

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by