フィルターのクリア

I'm trying to integrate, but I get an "undefined function" error.

2 ビュー (過去 30 日間)
Muhammad Faizan Asif
Muhammad Faizan Asif 2020 年 6 月 3 日
編集済み: Stephan 2020 年 6 月 3 日
This is my code:
syms ao an bn t
t = 0 : 0.1 : 2*pi;
x = sin(pi*t);
T = 2;
n = -10 : 1 : 10;
wo = (2*pi)/T;
ao = (1/T)*int(x, t)
an = (2/T)*int((x*cos(n*wo*t)), t)
bn = (2/T)*int((x*sin(n*wo*t)), t)
plot(ao, t, an, t, bn, t)
grid on
xaxis('t')
yaxis('x(t)')
Title('Coefficients of CTFS')
And this is the error I'm getting:
  4 件のコメント
Muhammad Faizan Asif
Muhammad Faizan Asif 2020 年 6 月 3 日
Okay. Is it possible to tell MATLAB about which variable I want to use to integrate my function with respect to?
Mohammad Sami
Mohammad Sami 2020 年 6 月 3 日
My apologies, the function int is only available in symbolic toolbox.
You can refer to the documentations here.

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

採用された回答

Stephan
Stephan 2020 年 6 月 3 日
編集済み: Stephan 2020 年 6 月 3 日
int does not accept numerical inputs, because it performs symbolic integration - so you have to define a numerical vector for t also - here t_num. This has to be the same size like an, and bn are to plot the results:
syms ao an bn t
x = sin(pi*t);
T = 2;
n = -10 : 1 : 10;
t_num = linspace(0,2*pi,numel(n));
wo = (2*pi)/T;
ao = (1/T)*int(x, 0, 2*pi)
an = (2/T)*int((x*cos(n*wo*t)), 0, 2*pi)
bn = (2/T)*int((x*sin(n*wo*t)), 0, 2*pi)
plot(ao, t_num, an, t_num, bn, t_num)
grid on
xlabel('t')
ylabel('x(t)')
title('Coefficients of CTFS')

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by