Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
Hi all,
My job is to find and plot the Fourier series of the wave(figure 8.png) up to a sensible n value.
Problems:
1- When I try to compute the f(t) using the symbolic engine it gives me (Error 1 and 2.png)
2- When I try to plot this, I get another error something along the lines of plot failed because of 'complex and Nans' or something along those lines.
I have attached my file and used legacy symbolic engine but still does not work.
Solved! Go to Solution.
But on closer observation, the problems are clear:
You defined f to be a function of 2 parameters: n and t.
Now n is used as a parameter to the function, but also as a running variable in the summation. Prime is fully in its right to complain.
When plotting it, you only supply a single parameter f(t)...
Does this come close?
Success!
Luc
Prime (as well as real mathcad) does not plot complex, imaginary or Not A numbers.
You've probably run into complex or imaginary numbers. You can see what's going on by plotting the Real and/or the Imaginary parts of the complex numbers. Use functions Re() and Im() to extract those parts for plotting.
Success!
Luc
But on closer observation, the problems are clear:
You defined f to be a function of 2 parameters: n and t.
Now n is used as a parameter to the function, but also as a running variable in the summation. Prime is fully in its right to complain.
When plotting it, you only supply a single parameter f(t)...
Does this come close?
Success!
Luc
Thanks man,
I removed f(t,n) to f(t) (note: I now changed t to theta because horizontal axis is supposed to be rad not seconds).
Having said that, there is still a problem that the max amplitude is around 1.5 not 1 volt as required. What might be the problem there? Have a look, I have attached an updated file.
(UPDATE: the previous errors regarding the symbolic engine disappeared upon restarting the program)
I see the cause of the problem.
Your signal is supposed to go down from 0 to -1 in the period for t between 0 and pi.
Does the function -t/pi do that for this range of values of t ?
Then from pi on, the function should go up from 0 to 1.
Does the function t/pi do that for the range of values of t from pi to 2pi ?
This should help you find the cause, and solve the problem.
Success!
Luc
😓
I FINALLY sorted it out. It seems that I am making many mistakes recently.
Anyway a small question: when I input units as V for voltage mathcad shows: '1/V *V ' , why is this and what does it mean?
It means that Prime does not agree with you, that f(theta) results in values that have a unit of V.
And it is perfectly right in that.
Where did you put units in the definition of f to make it result in Volts...?
Success!
Luc
I attached my file. I put my units in the y axis 'units placeholder'.
UPDATE: I define V in my previous f functions and now it works.
Bravo!
You don't need symbolics, but you do need to keep track of how many arguments your functions need.
Excellent response!
I had a look at the 'weird fourier' file and am impressed by it. You have used vector to store the Fourier coefficient(harmonics). For some reason it works way faster than the other file and can calculate up 200 n in only a few seconds where-as my other file takes a long time.
Your f(n,t) function calculates each coefficient EACH time it evaluates; storing them in vectors calculates them once.