Syntax of the equation below

y= (1./k)*(sin(k'*t))
this equation was used to find the sum of odd harmonics of sine wave. Can someone explain how this equation works?

Réponses (1)

KSSV
KSSV le 10 Juil 2017

0 votes

t = 0:.01:10;
figure
hold on
for k = 1:2:10
y = sin(k*t)/k;
plot(t,y)
end
Note that y = sin(f*t), f represents the frequency, here k (=f) takes only the odd frequencies. YOu can check that from the above plot.

3 commentaires

KSSV
KSSV le 10 Juil 2017
siva kumar commented:
Above equation which i have written worked.So please tell me what is the significance of . and '. Thank you
KSSV
KSSV le 10 Juil 2017
It calculates 1/k*sin(k*t) for each k and sum's them. This is same as:
t = 0:.01:10;
k = 1:2:10 ;
% y= (1./k)*(sin(k'*t)) ;
%
% plot(t,y) ;
yy = zeros(size(t)) ;
for i = 1:length(k)
yy = yy+1/k(i)*sin(k(i)*t) ;
end
plot(t,yy)
.* stands for element by element multiplication; ' this stands for transpose.
Walter Roberson
Walter Roberson le 10 Juil 2017
This does not find the sum of the harmonics, only plots them individually.
. has no meaning of its own in the original code. ./ is the name of an operator that is different than the / operator. The / operator is formally named as mrdivide and it is algebraic matrix division with A/B being similar to A*pinv(B) where * is algebraic matrix multiplication. The ./ that was used is element-by-element division, so 1./[3 5 7] would give you [1/3 1/5 1/7]
' is complex conjugate transpose. In the special case of working with real values, that is equivalent to transpose . That is, it would switch between row vector and column vector, or column vector and row vector.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Tags

Question posée :

le 10 Juil 2017

Commenté :

le 10 Juil 2017

Community Treasure Hunt

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

Start Hunting!

Translated by