- #1
radiodude
- 14
- 0
I'm trying to understand some MATLAB code. It's the Fourier series approximation of a signal. This is my first time using matlab, so I guess I'm really trying to comprehend the syntax.
For my example, I am using some code I googled (http://www.ee.nmt.edu/~wedeward/EE341/FA97/example8.html)
What I don't understand is the yce = yce + ... line (line 10). On that line you have
yce [vector]
cn [scalar]
j [scalar]
n [scalar]
wo [scalar]
t [vector]
So what does
vector = vector + scalar * exp(scalar * scalar * scalar * vector)
really evaluate to in matlab?
Does exp(vector) really mean it creates a new vector with entries:
e^old_vec_entry_for_t0
e^old_vec_entry_for_t1
...
e^old_vec_entry_for_tn
If so, then it makes sense as then it resolves to
vector = vector + scalar*vector
which is then
vector_running_sum = vector_running_sum + vector_values_for_all_t_from_neg_n_to_pos_n
For my example, I am using some code I googled (http://www.ee.nmt.edu/~wedeward/EE341/FA97/example8.html)
Code:
01 N = 11; % summation limit (use N odd)
02 wo = pi; % fundamental frequency (rad/s)
03 c0 = 0; % dc bias
04 t = -3:0.01:3; % declare time values
05
06 yce = c0*ones(size(t)); % initialize yce to c0
07
08 for n = -N:2:N, % loop over series index n
09 cn = 2/(j*n*wo); % Fourier Series Coefficient
10 yce = yce + cn*exp(j*n*wo*t); % Fourier Series computation
11 end
What I don't understand is the yce = yce + ... line (line 10). On that line you have
yce [vector]
cn [scalar]
j [scalar]
n [scalar]
wo [scalar]
t [vector]
So what does
vector = vector + scalar * exp(scalar * scalar * scalar * vector)
really evaluate to in matlab?
Does exp(vector) really mean it creates a new vector with entries:
e^old_vec_entry_for_t0
e^old_vec_entry_for_t1
...
e^old_vec_entry_for_tn
If so, then it makes sense as then it resolves to
vector = vector + scalar*vector
which is then
vector_running_sum = vector_running_sum + vector_values_for_all_t_from_neg_n_to_pos_n
Last edited: