How to plot delta of dirac from fourier transform result in Matlab GUI
27 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Walter Roberson
2021 年 7 月 30 日
eval() is likely to be the major error in the code, so the datatype and content matter a lot.
回答 (2 件)
Ashutosh Singh Baghel
2021 年 8 月 5 日
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 件のコメント
Walter Roberson
2021 年 8 月 5 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Calculus についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!