Hal Jordan

September 30th, 2012, 03:30 AM

Hi, it's my first time on these forums. I've used Ubuntu before but my question today isn't about Ubuntu, it's about Matlab. I read somewhere that all kinds of languages are discussed on these forums so I decided to try my luck here. My instructor assigns such long projects every week that are very time-consuming but does not really take the time to explain the subject.

I want to write a program that plots one peicewise function

f(t) = -Pi*t on −1 ≤ t ≤ 0 and Pi*t on 0 < t ≤ 1 and one Fourier Series F(t) = Pi/2 - 4/Pi Sum[(1/2k+1)*Pi*t*cos(2k-1)] k = 1 to Infinity on −1 ≤ t ≤ 1 using the fplot command. It's only my fourth assignment using Matlab so it's a bit of a jump going from one plot to two or more on the same graph. I wanted to show that I made an attempt at the problem so here is my code so far:

function Ft = Fourier(t)

% Ft = Fourier(t)

% INPUT

% t: Values between -1 and 1

%

% OUTPUT

% Ft: Fourier approximation

%

a=(0:9);

n=numel(a);

term(i)=1./(((2.*a(i)-1.^2)).*cos ((2.*a(i)-1)).*pi.*t);

[x,y]=fplotf(Ft,[-1,1])

plot(x,y)

end

Any help would be appreciated.

I want to write a program that plots one peicewise function

f(t) = -Pi*t on −1 ≤ t ≤ 0 and Pi*t on 0 < t ≤ 1 and one Fourier Series F(t) = Pi/2 - 4/Pi Sum[(1/2k+1)*Pi*t*cos(2k-1)] k = 1 to Infinity on −1 ≤ t ≤ 1 using the fplot command. It's only my fourth assignment using Matlab so it's a bit of a jump going from one plot to two or more on the same graph. I wanted to show that I made an attempt at the problem so here is my code so far:

function Ft = Fourier(t)

% Ft = Fourier(t)

% INPUT

% t: Values between -1 and 1

%

% OUTPUT

% Ft: Fourier approximation

%

a=(0:9);

n=numel(a);

term(i)=1./(((2.*a(i)-1.^2)).*cos ((2.*a(i)-1)).*pi.*t);

[x,y]=fplotf(Ft,[-1,1])

plot(x,y)

end

Any help would be appreciated.