The following error was reported evaluating the function in FunctionLine update: Unable to convert expression containing symbolic variables into double array. Apply 'subs' function first to substitute values for variables.

11 次查看(过去 30 天)
Hi! I am trying to plot a fourier function by using fplot but I am getting the following error.
The following error was reported evaluating the function in FunctionLine update: Unable to convert expression containing symbolic variables into double array.
Apply 'subs' function first to substitute values for variables.
syms f(t) g(t) w;
x=@(t)heaviside(exp(-20*t));
h=@(t) heaviside(12.*t.*exp(55*t));
xf=vpa(fourier(f,t,w));
hf=vpa(fourier(g,t,w));
fplot(@(w) abs(hf), [-20*pi 20*pi])
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your function to return an output with the same size and shape as the input arguments.
Warning: Error updating FunctionLine.

The following error was reported evaluating the function in FunctionLine update: Unable to convert expression containing symbolic variables into double array. Apply 'subs' function first to substitute values for variables.
  11 个评论
Rik
Rik 2020-12-21
Which function exactly do you want to plot? As Walter mentioned below, you can't plot the idea of a Fourier transform. I expect you want to plot the Fourier transform of either x or h. You don't actually use either in your current code.

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2020-12-20
fplot(abs(hf), [-20*pi 20*pi])
  14 个评论
Torsten
Torsten 2024-7-24
编辑:Torsten 2024-7-24
If you use the Taylor method to solve ordinary differential equations, you won't approximate the solution only once for the initial conditions and take this polynomial as solution over the complete interval of integration as done above. You will use it for a (usually) low order and a small stepsize h to approximate the solution y in x0+h and proceed from there, taking x0 + h and y(x0+h) as new initial conditions.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by