Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Mar 09, 2021
03:46 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Mar 09, 2021
03:46 PM

Fourier series of a half symmetrical wave not working

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.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

Mar 09, 2021
04:20 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Mar 09, 2021
04:20 PM

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

13 REPLIES 13

Mar 09, 2021
04:05 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Mar 09, 2021
04:05 PM

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

Mar 09, 2021
04:20 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Mar 09, 2021
04:20 PM

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

Mar 09, 2021
04:33 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Mar 09, 2021
04:33 PM

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)

Mar 09, 2021
04:39 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Mar 09, 2021
04:39 PM

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

Mar 09, 2021
05:11 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Mar 09, 2021
05:11 PM

😓

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?

Mar 09, 2021
05:17 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Mar 09, 2021
05:17 PM

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

Mar 09, 2021
05:22 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Mar 09, 2021
05:22 PM

I attached my file. I put my units in the y axis 'units placeholder'.

Mar 09, 2021
05:29 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Mar 09, 2021
05:29 PM

UPDATE: I define V in my previous f functions and now it works.

Mar 09, 2021
05:30 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Mar 09, 2021
05:30 PM

Bravo!

Mar 09, 2021
04:48 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Mar 09, 2021
04:48 PM

You don't need symbolics, but you do need to keep track of how many arguments your functions need.

Mar 09, 2021
05:36 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Mar 09, 2021
05:36 PM

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.

Mar 09, 2021
06:58 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Mar 09, 2021
08:04 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Mar 09, 2021
08:04 PM

Your f(n,t) function calculates each coefficient EACH time it evaluates; storing them in vectors calculates them once.