MATH 3150: Problem Solving with Fourier Series - Problems 2.2.7, 2.2.9, 2.2.11, 2.2.13, Assignments of Mathematics

Matlab code for solving problems related to fourier series. The problems involve plotting functions and computing partial fourier series. The code is for math 3150, a university-level mathematics course.

Typology: Assignments

Pre 2010

Uploaded on 08/31/2009

koofers-user-wmj
koofers-user-wmj ๐Ÿ‡บ๐Ÿ‡ธ

10 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
pf3
pf4
pf5

Partial preview of the text

Download MATH 3150: Problem Solving with Fourier Series - Problems 2.2.7, 2.2.9, 2.2.11, 2.2.13 and more Assignments Mathematics in PDF only on Docsity!

0.2^ 0.

0.6^ 0.

x

x

  • 0.1 0 โˆ’2
  • 0.2 0.
  • 0.4 0.
  • 0.6 0.
  • 0.8 0.

โˆ’2^ โˆ’

x

% MATH 3150

F a l l^2008 % Problem

t h i c k L i n e s ( 3 ) ;

% remove

i f^ you^ don โ€™ t

have^ t h i s

i n

your^ system f i g u r e^ ( 1 ) ;^ c l f

x =^ linspace

(โˆ’pi^ , 3^ โˆ—^ pi

%^ p l o t^ t r u e

f u n c t i o n

f o r^ r e f e r n c e hold^ on ; plot^ ( x ,^ sin

( x ). ห† 2 ) ; axis^ ([^ โˆ’^ pi

, 3^ โˆ—^ pi^ , 0 , 1 ] ) ; %^ l o o p^ o v e r

number^ o f

terms plot^ ( x , 1 / 2

โˆ—^ o n e s (^ s i z e

( x ) ) , โ€™ r โ€™ ) ; plot^ ( x ,1/

โˆ—(1^ โˆ’^ cos^ ( 2

โˆ—^ x ) ) , โ€™ g โ€™ ) ; f i l e n a m e^

=^ โ€™ p 2^2 1 1. e p s โ€™ ; xlabel^ ( โ€™ x โ€™ ) ; print^ ( โ€™โˆ’d e p s c 2 โ€™ , f i l e n a m e ) ;system ( [ โ€™ e p s t o p d f

โ€™ , f i l e n a m e ] ) ;

% MATH 3150

F a l l^2008 % Problem

t h i c k L i n e s ( 3 ) ;

% remove

i f^ you^ don โ€™ t

have^ i t^

i n

your^ system f i g u r e^ ( 1 ) ;^ c l f

x =^ linspace

(โˆ’pi^ , 3^ โˆ—^ pi

%^ p l o t^ t r u e

f u n c t i o n

f o r^ r e f e r n c e hold^ on ; %^ t r i c k^ t o

make^2 โˆ—^ p i

p e r i o d i c

f u n c t i o n

from^ f n

d e f^ on^ [ 0 , 2

โˆ—^ p i ] plot^ ( x , ( mod( x+

pi^ , 2^ โˆ—^ pi^ )โˆ’

pi^ ) ) ; axis^ ([^ โˆ’^ pi^

, 3^ โˆ—^ pi^ ,โˆ’^ pi

โˆ—^ 1. 2 ,^ pi^ โˆ—^ 1. 2 ] ) ; %^ l o o p^ o v e r

number^ o f

terms Ns =^ [ 1 , 2 , 5 , 1 0 , 1 5 ] ;c o l s ={^ โ€™ g โ€™ , โ€™mโ€™ , โ€™ c โ€™ , โ€™ r โ€™ , โ€™ k โ€™

}^ ;

for^ iN =^

1 :^ length^ ( Ns ) ,N=Ns ( iN ) ; % compute^ p a r t i a l^

F o u r i e r^ s e r i e s s=zeros^ (^ s i z e

( x ) ) ; for^ n=1:N,an =^ โˆ’^2 โˆ—

(โˆ’1)ห†n/n ;s=s+anโˆ— sin^ ( nโˆ—x ) ; end^ ; %^ c o m p a r a t i v e

p l o t plot^ ( x , s , c o l s

{^ iN^ }^ ) ; end^ ;%N hold^ o f f ;^ xlabel^ ( โ€™ x โ€™ ) ;f i l e n a m e= โ€™ p 2

2 1 3. e p s โ€™ ; print^ ( โ€™โˆ’d e p s c 2 โ€™ , f i l e n a m e ) ;system ( [ โ€™ e p s t o p d f

โ€™^ f i l e n a m e ] ) ;