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.

12 vues (au cours des 30 derniers jours)
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 commentaires
Rik
Rik le 21 Déc 2020
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.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 20 Déc 2020
fplot(abs(hf), [-20*pi 20*pi])
  14 commentaires
Torsten
Torsten le 24 Juil 2024
Modifié(e) : Torsten le 24 Juil 2024
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.

Connectez-vous pour commenter.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by