how can i calculate fourier?

2 visualizaciones (últimos 30 días)
Pablo Álvarez García
Pablo Álvarez García el 12 de Feb. de 2022
Editada: John D'Errico el 12 de Feb. de 2022
clear all;
close all;
syms t s w
Gs=1/(s+5);
Gjw=subs(Gs,s,j*w);
%creamos la onda cuadrada con T=6s
A=1;
Fs=10000;
f=0.1666; T=3*(1/f);
c=50;
t=0:1/Fs:T-1/Fs;
x=A*square(2*pi*f*t,c)%onda cuadrada de T=6s
X=fourier(x)
%It gives me this error: Undefined function 'fourier' for input arguments of type 'double'.

Respuestas (1)

John D'Errico
John D'Errico el 12 de Feb. de 2022
FOURIER is a function that is part of the symbolic toolbox. If you do not have that toolbox, then you could not use it. However, your problem is that you are trying to use it on a sequence of numbers, not on a true square wave. And the function SQUARE is part of the signal processing toolbox. It works with numbers and series of them.
So if you want to compute a symbolic Fourier series, then you need to create symbolic objects. If you want to compute a fast fourier transform, which can be used on pure numbers, then use FFT. But only you know what it is you really wanted to do here.
  2 comentarios
Pablo Álvarez García
Pablo Álvarez García el 12 de Feb. de 2022
I want to calculate the fourier expresssion and then plot it
John D'Errico
John D'Errico el 12 de Feb. de 2022
Editada: John D'Errico el 12 de Feb. de 2022
Sigh. Yet you still have not decided if you want to do this in a symbolic form, and plot THAT in some way, or if you want to compute the FFT, and plot that.
fourier is a function that works on symbolic expressions. My guess is you really wanted to compute the FFT. So use fft. Remember that it will have real and imaginary components. So you will need to decide how to plot a complex variable. What will be on the x axis? The y axis?
Or, maybe you are asking how to compute a fourier expansion of that sequence, and then reconstitute the original function from the truncated Fourier approximation you computed via FFT, and see what it looks like. For example, do you see Gibbs phenomena around the edges of the square wave?

Iniciar sesión para comentar.

Categorías

Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by