Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: help with writing a short program using square waves, fourier
series expansion

Replies: 3   Last Post: Feb 21, 2013 10:06 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Derek Goring

Posts: 3,919
Registered: 12/7/04
Re: help with writing a short program using square waves, fourier
series expansion

Posted: Feb 18, 2013 9:50 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On Tuesday, February 19, 2013 2:37:06 PM UTC+13, laura wrote:
> A square wave of period 2L is a step function which is equal to 1 for x from 0 to L, then is equal to -1 for x from L to 2L.
>
>
>
> A square wave can be approximated by this Fourier Series expansion:
>
> infinity
>
> f(x )=(4/pi) ?((1/n)sin(npix/L))
>
> n=1,2,3,5....
>
> I need to write a program that prompts the user for a maximum value for n and a value for L. Using those values, I have to compute the Fourier Series expansion for a square wave and plot the result.
>
> L must be a positive number, and n must be a positive odd integer. If the user does not provide an acceptable number, you should detect the error, display an error message, and stop your script.
>
> You should evaluate the function for 500 values of x, evenly distributed from 0 to 2L.
>
>
>
> I know this is alot but I have no idea how to even start it! If you can at least start me off that would be great!
>
> I know i need to get an input, detect an error, stop the script, and evenly distrubute 500 points im just not sure how. thanks again!


Here's what you need to get you started:
help input

Now, you write some code and when you get stuck come back here and ask for help.
But don't expect us to do your homework for you.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.