Syntax of the equation below

1 回表示 (過去 30 日間)
siva kumar
siva kumar 2017 年 7 月 10 日
コメント済み: Walter Roberson 2017 年 7 月 10 日
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 件のコメント
Walter Roberson
Walter Roberson 2017 年 7 月 10 日
What are size(k) and size(t) ?

サインインしてコメントする。

回答 (1 件)

KSSV
KSSV 2017 年 7 月 10 日
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 日
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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by