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