Plotting Fourier transform with heaviside functions
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, when running this code
syms s(t)
syms j(w)
s(t) = 2 * cos(2*t + 1) * heaviside(t - 2*fix(t/2)) * heaviside(-t + 2/10 + 2*fix(t/2));
j(w) = fourier(s, t, w);
ezplot(j);
I get the following output
Error using inlineeval (line 15) Error in inline expression ==> 2.*fourier(heaviside(2.*fix(t./2) - t + 1./5).*cos(2.*t + 1).*heaviside(t - 2.*fix(t./2)), t, w) Undefined function 'fourier' for input arguments of type 'double'.
Error in inline/feval (line 34) INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr);
Error in ezplotfeval (line 54) z = feval(f,x(1),y(1));
Error in ezplot>ezimplicit (line 258) u = ezplotfeval(f, X, Y);
Error in ezplot (line 154) hp = ezimplicit(cax, f{1}, vars, labels, args{:});
Error in sym/ezplot (line 61) h = ezplot(fhandle(f));
Error in Untitled5 (line 7) ezplot(j);
Could anyone help me?
0 Kommentare
Antworten (1)
Star Strider
am 17 Jul. 2014
Using the fix function is well-intended but not necessary in symbolic operations. To use heaviside, you need to cast the arguments as symbolic to get a symbolic result. (You can always use matlabFunction to create an anonymous function out of it to use outside of the Symbolic Math Toolbox.)
This works:
syms s(t)
syms j(w)
s(t) = 2 * cos(2*t + 1) * heaviside(sym(t - 2*(t/2))) * heaviside(sym(-t + 2/10 + 2*(t/2)));
j(w) = fourier(s, t, w);
ezplot(j);
although the plot is not informative.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Calculus finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!