How to plot delta of dirac from fourier transform result in Matlab GUI
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello everyone,
Im trying to plot any answer of fourier transform (for example) and some of the answers is delta of dirac, the problem is that the matlab GUI do not make the plot at all.
Im using symbolic.
How can i solve this problem?
Thank's.
this is a part of my code to ploting the answer:
elseif app.command2(1) == "fourier"
app.UIAxes2.XLabel.String='w';
app.UIAxes.XLabel.String='t';
fplot(app.UIAxes, eval(app.command2(4))); % original function
fplot(app.UIAxes2,app.answer); % fourier result
3 comentarios
Walter Roberson
el 30 de Jul. de 2021
eval() is likely to be the major error in the code, so the datatype and content matter a lot.
Respuestas (2)
Ashutosh Singh Baghel
el 5 de Ag. de 2021
Hi Yoav,
From my understanding, you want to ‘plot’ dirac delta using MATLAB App. Updating the callback function by using “fft” function in MATLAB may solve the issue. For an example –
Ts = 1/50; %Sampling Period
t = 0:Ts:10-Ts; %time domain abscissa variable
x = sin(2*pi*15*t) + sin(2*pi*20*t); %time domain ordinate variable
y = fft(x); %take fft of x for frequency domain ordinate variable
fs = 1/Ts; %sampling frequency
f = (0:length(y) -1)*fs/length(y); %frequency domain abscissa variable
plot(f,abs(y));
A reference guide for using 'fourier' functions can be found in the Fourier Transforms MATLAB Documentation page.
0 comentarios
Walter Roberson
el 5 de Ag. de 2021
When you talk about the result of the fourier transform being in terms of dirac(), that tells me you are using symbolic fourier transform and that you are seeing dirac() calls in the output of fourier() calls.
fplot(app.UIAxes, eval(app.command2(4))); % original function
If app.command2(4) is a symbolic expression or symbolic function, then eval() of it is equivalent to eval() of char() of it, as if you had written
fplot(app.UIAxes, eval(char(app.command2(4)))); % original function
Depending exactly what it contains and what values have been assigned to variables, this can trigger dirac() being evaluated with a numeric argument instead of being evaluated with a symbolic number.
With sufficiently old versions of MATLAB, dirac() was not defined for numeric values, and the call would fail.
Never use eval() on a symbolic expression or symbolic function. eval() assumes that the content to be evaluated is written in MATLAB code, but char() of symbolic expressions do not result in MATLAB code, only something that is similar to MATLAB.
0 comentarios
Ver también
Categorías
Más información sobre Number Theory en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!