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?

답변 (1개)

KSSV
KSSV 2017년 7월 10일

0 개 추천

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

KSSV
KSSV 2017년 7월 10일
siva kumar commented:
Above equation which i have written worked.So please tell me what is the significance of . and '. Thank you
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 2017년 7월 10일
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.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

2017년 7월 10일

댓글:

2017년 7월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by