When I integrate a constant over Tp I should get the constant but I don't?

1 次查看(过去 30 天)
I'm attempting to find the average value but have come up against a error.
When I integrate a constant over Tp I should get the constant but I don't?
>> T= 2*pi
>> ao=(1/T)*int(100.0,t,0,T) %Integrate the constant 100 over Tp to find the average
ao =
(143354028480566475*pi)/4503599627370496

采纳的回答

Stephan
Stephan 2019-1-13
编辑:Stephan 2019-1-13
Hi,
int is a Symbolic Toolbox function. Use either double or integral for direct numeric computation.
a0 = double((1/T)*int(100.0,t,0,T))
  2 个评论
Gary Armstrong
Gary Armstrong 2019-1-14
clear all
syms t n
T= 2*(pi); % T= Period
w0=1; % Fundamental anguler freg
%n=1:10; % n=1 fundamental, n>1 harmonics
v =100+100*cos(w0*t);
a0= double( (1/T)*int(v(t),t,0,T))
an= double( (2/T)*int(v(t)*cos(n*w0*t),t,0,T))
bn= double( (2/T)*int(v(t)*sin(n*w0*t),t,0,T))
Error using sym/subsindex (line 825)
Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function arguments must be
symbolic variables, and function body must be sym expression.
Error in sym/subsref (line 870)
R_tilde = builtin('subsref',L_tilde,Idx);
Stephan
Stephan 2019-1-14
syms t n
T= 2*sym('pi'); % T= Period
w0=1; % Fundamental anguler freg
n=1:10; % n=1 fundamental, n>1 harmonics
v =100+100*cos(w0*t);
a0= 1/T*int(v,t,0,T)
an= 2/T*int(v*cos(n*w0*t),t,0,T)
bn= 2/T*int(v*sin(n*w0*t),t,0,T)

请先登录,再进行评论。

更多回答(1 个)

Walter Roberson
Walter Roberson 2019-1-14
syms t
T = 2 * sym('pi'); %use symbolic pi instead of numeric pi
ao=(1/T)*int(100.0,t,0,T)
  2 个评论
Gary Armstrong
Gary Armstrong 2019-1-14
clear all
syms t n
T= 2*sym('pi'); % T= Period
w0=1; % Fundamental anguler freg
%n=1:10; % n=1 fundamental, n>1 harmonics
v =100+100*cos(w0*t);
a0= double( (1/T)*int(v(t),t,0,T))
an= double( (2/T)*int(v(t)*cos(n*w0*t),t,0,T))
bn= double( (2/T)*int(v(t)*sin(n*w0*t),t,0,T))
Error using sym/subsindex (line 825)
Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function arguments must be
symbolic variables, and function body must be sym expression.
Error in sym/subsref (line 870)
R_tilde = builtin('subsref',L_tilde,Idx);

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Formula Manipulation and Simplification 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by