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.
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.
Why did you edit away your question and delete your comment? That is very rude. Luckily Google cache still contains the original question and the comment.
If you keep removing the code from your question I will keep putting it back (until a Mathworks employee tells me otherwise). I bet I'm more stubborn than you are.
Out of respect for the response you did get. Walter spent time reading your question, understanding your problem and writing a suggested solution. If that is not the complete solution you can follow up with comments.
You should also note that some questions don't have proper answers. That is also valuable knowledge.
I showed my respect by saying thank you and I could not solve my problem so there is no need to keep this in here. Moreover I dont want people to get confused with that unsolved problem. Is that enough for removing that. By the way I also did not want to be disrescpect to you that issue more about my bad languange.
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.
The question itself was:
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.
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.
Nothing. You cannot illustrate the general idea of fourier transformation without using a series of plots. I recommend that you look at Wikipedia or some textbooks to see how they illustrate the general idea of fourier transform of unknown functions.
In the meantime, I would like to ask you why you go through the trouble to calculate xf but do not display the results and do not plot it? Why do you suddenly turn around and want to plot the fourier transform of the unknown function g?
The following error was reported evaluating the function in FunctionLine update: Unable to convert expression containing remaining symbolic function calls into double array. Argument must be expression that evaluates to number.
I don't understand what you try to do in the code. A Taylor series in two dimensions of z(x,y) = x-y^2 ? But why do you define y as a function of x then ?
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.