MATLAB中绘制符号变量的错误?

发布于 2025-01-24 07:04:58 字数 1346 浏览 3 评论 0 原文

我正在尝试从

第312页的“信号和系统实验室”中学习傅立叶变换,以下是遵循代码的,这表明可以通过乘以两个信号的傅立叶变换来实现卷积

syms t w
x1=heaviside(t)-heaviside(t-2);
x2=heaviside(t)-heaviside(t-4);
X1=fourier(x1,w);
X2=fourier(x2,w);
right=ifourier(X1*X2,t)
ezplot(right)

我尝试了MATLAB 2019和MATLAB 2020,但是

实际上,当我尝试在MATLAB中运行代码上方时,我都会

Error using inlineeval (line 14)
Error in inline expression ==> (t.*pi.*sign(t) + fourier(cos(2.*w)./w.^2, w, -t) +
fourier(cos(4.*w)./w.^2, w, -t) - fourier(cos(6.*w)./w.^2, w, -t) - fourier(sin(2.*w)./w.^2, w,
-t).*1i - fourier(sin(4.*w)./w.^2, w, -t).*1i + fourier(sin(6.*w)./w.^2, w, -t).*1i)./(2.*pi)
 Undefined function 'fourier' for input arguments of type 'double'.

Error in inline/feval (line 33)
        INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr);

Error in ezplotfeval (line 53)
    z = feval(f,x(1),y(1));

Error in ezplot>ezimplicit (line 271)
    u = ezplotfeval(f, X, Y);

Error in ezplot (line 167)
                hp = ezimplicit(cax, f{1}, vars, labels, args{:});

Error in sym/ezplot (line 66)
   h = ezplot(fhandle(f)); %#ok<EZPLT>

Error in Untitled (line 7)
ezplot(right)

遇到同样的问题。 a href =“ https://i.sstatic.net/o5suz.jpg” rel =“ nofollow noreferrer”>

I am trying to learn fourier transform from book"signals and systems laboratory with matlab alex palamides"

On page 312, following code is given which demonstrates that convolution can be implemented by multiplying the fourier transforms of two signals and then taking the inverse fourier of product

syms t w
x1=heaviside(t)-heaviside(t-2);
x2=heaviside(t)-heaviside(t-4);
X1=fourier(x1,w);
X2=fourier(x2,w);
right=ifourier(X1*X2,t)
ezplot(right)

I tried MATLAB 2019 and MATLAB 2020 but i get same problem in both

Actually When i try to run above code in my MATLAB i don't get output like the one in book, instead i get following error

Error using inlineeval (line 14)
Error in inline expression ==> (t.*pi.*sign(t) + fourier(cos(2.*w)./w.^2, w, -t) +
fourier(cos(4.*w)./w.^2, w, -t) - fourier(cos(6.*w)./w.^2, w, -t) - fourier(sin(2.*w)./w.^2, w,
-t).*1i - fourier(sin(4.*w)./w.^2, w, -t).*1i + fourier(sin(6.*w)./w.^2, w, -t).*1i)./(2.*pi)
 Undefined function 'fourier' for input arguments of type 'double'.

Error in inline/feval (line 33)
        INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr);

Error in ezplotfeval (line 53)
    z = feval(f,x(1),y(1));

Error in ezplot>ezimplicit (line 271)
    u = ezplotfeval(f, X, Y);

Error in ezplot (line 167)
                hp = ezimplicit(cax, f{1}, vars, labels, args{:});

Error in sym/ezplot (line 66)
   h = ezplot(fhandle(f)); %#ok<EZPLT>

Error in Untitled (line 7)
ezplot(right)

Snapshot of book page also attached hereenter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

守不住的情 2025-01-31 07:04:58

我在 matlab答案。解决的解决方案
walter roberson> .com/help/symbolic/rewrite.html“ rel =“ nofollow noreferrer”>重写 x1*x1*x2 exp 中,在服用逆傅立叶变换。引用MATLAB答案:

在您发布matlab时,ezplot()与绘制符号表达式不兼容,而必须使用fplot()。
但是, ifourier()给出了无法使用的结果,即 ezplot() nor fplot() 可以使用。
从R2012a有效的工作范围为:

  right = ifourier(reprite(x1*x2,'exp'),t);
FPLOT(右,[0 8])
 

结果(在R2021b上):

I found the same question on MATLAB Answers. The solution as posted by
Walter Roberson is to rewrite X1*X2 in terms of exp before taking the inverse fourier transform. Quoting from MATLAB Answers:

In your release of MATLAB, ezplot() was not compatible with plotting symbolic expressions, and fplot() had to be used instead.
However, the ifourier() is giving unusable results that neither ezplot() nor fplot() can use.
The work-around, valid from R2012a, is:

right = ifourier( rewrite(X1*X2, 'exp'), t);
fplot(right, [0 8])

Result (on R2021b):

result

可是我不能没有你 2025-01-31 07:04:58

看来matlab不能 x1*x2 ,因此它将反傅立叶变换返回,作为未评估的呼叫转换为傅立叶。

>> right

right =
 
(pi*t*sign(t) + fourier(cos(2*w)/w^2, w, -t) + fourier(cos(4*w)/w^2, w, -t) - fourier(cos(6*w)/w^2, w, -t) - fourier(sin(2*w)/w^2, w, -t)*1i - fourier(sin(4*w)/w^2, w, -t)*1i + fourier(sin(6*w)/w^2, w, -t)*1i)/(2*pi)

ezplot fplot 无法绘制这样的表达式。

It looks like matlab cannot transform the function X1*X2, so it returns the inverse fourier transform as an unevaluated call to fourier.

>> right

right =
 
(pi*t*sign(t) + fourier(cos(2*w)/w^2, w, -t) + fourier(cos(4*w)/w^2, w, -t) - fourier(cos(6*w)/w^2, w, -t) - fourier(sin(2*w)/w^2, w, -t)*1i - fourier(sin(4*w)/w^2, w, -t)*1i + fourier(sin(6*w)/w^2, w, -t)*1i)/(2*pi)

ezplot, or fplot can not plot a expression like this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文