I'm new to Matlab and I'm completely lost with one of the programs that was assigned to me, please help!

Here is the link to the program/assignment, someone please help.
I don't want the answer, I just need assistance on how to do this because I don't even know how to start.

2 Comments

The last sentence is such important, that I vote for this question. I've moved it from the comments to the question.

Sign in to comment.

 Accepted Answer

hi, Your program has :
Inputs : Half period L and number of iterations N .
Outputs : A vector that approximates a square wave .
L=2; % Half Period .
N=9; % Number of iterations
f=0; % Output .
T=l.......(0,2*L,500) %Incomplete line, A Mat function that creates linearly spaced vectors , it starts with lin...
for n=1:2:N
f=f+(4/(n*pi))*sin(n*pi*T/L); % Fourier series
end
figure, plot(T,f)
In the loop , after each iteration (4/(n*pi))*sin(n*pi*T/L) is added to (4/((n-1)*pi))*sin((n-1)*pi*T/L), and so on...
what is left :
1) Prompts for inputs L and N .
2) check if N is odd and L is >0 otherwise use function "error" .
3) Increase the number of iterations .

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!