- #1
Boltzmann
- 7
- 2
Hello,
I'm new here and I'm also new in programming. I never did it before and now I have a problem with one of the programs in fortran 90 and I can't figure out how to solve it. Maybe some of you can help me. Many thanks in advance.
1. Homework Statement
I need to plot the results of a Fourier series. In the first column the time and in the followings the results and the changes if the degree changes. Therefore I need to create a matrix. And that's where I have the problems. I can't figure out, how to choose the format.
Here is how I tried it. It works if I choose a 4x4 matrix and step=1, so that I only get 4 results of each but I want to use a step like 0.1 and a higher degree of the series therefore I need at least a 32x4 matrix. When I change the 4x4 matrix to anything else, the output starts getting messed up.
Here is my program
I'm new here and I'm also new in programming. I never did it before and now I have a problem with one of the programs in fortran 90 and I can't figure out how to solve it. Maybe some of you can help me. Many thanks in advance.
1. Homework Statement
I need to plot the results of a Fourier series. In the first column the time and in the followings the results and the changes if the degree changes. Therefore I need to create a matrix. And that's where I have the problems. I can't figure out, how to choose the format.
Homework Equations
The Attempt at a Solution
Here is how I tried it. It works if I choose a 4x4 matrix and step=1, so that I only get 4 results of each but I want to use a step like 0.1 and a higher degree of the series therefore I need at least a 32x4 matrix. When I change the 4x4 matrix to anything else, the output starts getting messed up.
Here is my program
Fortran:
PROGRAM fourier
IMPLICIT NONE
INTEGER :: b, i
REAL :: t, x, step=1,a
REAL, PARAMETER :: pi= 4.D0*DATAN(1.D0)
REAL :: r(4,4)=0.0
!READ (*,*) step
x=0
t=0
i=1
! OPEN (15,file="Data.dat")
DO WHILE ( t<pi )
DO b=0,2
a=b
x=x+1/(2*a+1)*SIN((2.0*a+1)*t)
r(b+2,i)=x
! WRITE(*,*) x,t
ENDDO
r(1,i)=t
t=t+step
i = i+1
x=0
!WRITE (*,*) t
ENDDO
!WRITE (*,*) t
WRITE(*,'(4(F9.6,X))') r
END PROGRAM fourier
Last edited by a moderator: