フィルターのクリア

How to integrate a signal sawtooth?

6 ビュー (過去 30 日間)
moustafa abada
moustafa abada 2020 年 3 月 6 日
コメント済み: Star Strider 2020 年 3 月 6 日
I'm integrrating the signal sawtooth using the function "integral" such that "0" min limit and "i" is the max limit to get values of theta to plot it with time but there is an error 'Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.'
Can you help please ?
fs = 1000;
kf=1000;
t = 0:1/fs:2;
signal = @(tt) sawtooth(pi*2*tt+pi);
theta=[];
for i = (0:1/fs:2)
theta=2*pi*kf*integral(signal,0,i);
end
plot(t,theta[i])

採用された回答

Star Strider
Star Strider 2020 年 3 月 6 日
Try this:
fs = 1000;
kf=1000;
t = 0:1/fs:2;
signal = @(tt) sawtooth(pi*2*tt+pi);
theta=zeros(size(t));
for i = 1:numel(t)
theta(i)=integral(signal,0,t(i));
end
figure
plot(t,theta)
It is necessary here to subscript ‘t’ and ‘theta’ in the loop to create the desired vectors.
  2 件のコメント
moustafa abada
moustafa abada 2020 年 3 月 6 日
Thanks a lot. It workd!
Star Strider
Star Strider 2020 年 3 月 6 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by