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?

Antworten (1)

KSSV
KSSV am 10 Jul. 2017

0 Stimmen

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 Kommentare

KSSV
KSSV am 10 Jul. 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 am 10 Jul. 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 am 10 Jul. 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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 10 Jul. 2017

Kommentiert:

am 10 Jul. 2017

Community Treasure Hunt

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

Start Hunting!

Translated by