- #1

- 136

- 0

Ive found the coefficients by hand, but now I need to use matlab to evaluate and tabulate the first 8 terms.

I then have to evaluate the series at 1000 points over a certain range.

Does someone know how to go about this?

- MATLAB
- Thread starter morry
- Start date

- #1

- 136

- 0

Ive found the coefficients by hand, but now I need to use matlab to evaluate and tabulate the first 8 terms.

I then have to evaluate the series at 1000 points over a certain range.

Does someone know how to go about this?

- #2

- 3

- 0

Then use ifft(vector). You'll get the coefficients (if you want 1000, get the first 1000).

Suppose you have a cosine transform.

f=f0+2*f1*cos*(w*x)+2*f2*cos(2*w*x)+2*f3*cos(3*w*x)+...

ifft will give you these coefficients f0, f1, f2...

If you want to reconstruct the function by yourself in matlab, you'll have to code a for loop.

start with f=f0.

then a variable for from 2:(the number of components you want)

add to f

end;

I hope this is clear. You should do the same thing with the 8 modes you calculated by hand.

- #3

- 136

- 0

Thanks anaemic.

- #4

- 4

- 0

If I don't discretize my function, then, I have to find the coefficient by numerical integration.

quad(f,-1,1)

where my f depends on n (the index of coefficient). And Matlab just says something like "dimension mismatch". Do you guys know how to deal with it?

I can actually do it like this:

for n=-N:N

fexp=@(x) (x+2).*exp(i*pi*n*x);

c(n+N+1)=quad(fexp,-0.5,0.5);

end

but I don't like to do it like this because this method seems to take a lot of computer time.

quad(f,-1,1)

where my f depends on n (the index of coefficient). And Matlab just says something like "dimension mismatch". Do you guys know how to deal with it?

I can actually do it like this:

for n=-N:N

fexp=@(x) (x+2).*exp(i*pi*n*x);

c(n+N+1)=quad(fexp,-0.5,0.5);

end

but I don't like to do it like this because this method seems to take a lot of computer time.

Last edited:

- Last Post

- Replies
- 3

- Views
- 1K

- Last Post

- Replies
- 4

- Views
- 83K

- Last Post

- Replies
- 0

- Views
- 6K

- Last Post

- Replies
- 1

- Views
- 6K

- Replies
- 1

- Views
- 6K

- Replies
- 4

- Views
- 26K

- Replies
- 6

- Views
- 6K

- Last Post

- Replies
- 1

- Views
- 18K

- Last Post

- Replies
- 3

- Views
- 3K

- Last Post

- Replies
- 1

- Views
- 2K