Evaluating the integral of a function?

조회 수: 3 (최근 30일)
ROSHAN SINGH
ROSHAN SINGH 2015년 8월 18일
댓글: ROSHAN SINGH 2015년 8월 19일
I want to evaluate integral of (Hr(w)*cos(n*w*t)-Hi(w)sin(n*w*t))dw with limits 1 to 2 where t=0.2 and T=2000. where Hr(w) is the real part of a function H(w)=10*(((i*w)/0.006)-1)*((-(w^2)/0.64)+(((2*(i*w))/0.8)+1))*(((i*w)/10)-1)*((-(w^2)/2250000)+(((2*(i*w))/1500)+1))/((((w^2)/0.000004)+(((2*(i*w))/0.002)+1))*((-(w^2)/49)+(((2*(i*w))/7)+1))*((-(w^2)/400000000)+(((2*(i*w))/20000)+1))*(((i*w)/100)-1))? And w is a vecor from [0.0005 to 5].
I am trying the following codes but the integral is not happening and instead it shows the error Undefined function 'int' for input arguments of type 'double
w=[0.0005:0.1:5]; n=1:length(w); t=0.1; T=2000;
for j=1:length(w) y(j)=10*(((i*w(j))./0.006)-1)*((-(w(j).^2)./0.64)+(((2*(j.*w(j)))./0.8)+1))*(((j.*w(j))./10)-1)*((-(w(j).^2)./2250000)+(((2*(j.*w(j)))./1500)+1))/((((w(j).^2)./0.000004)+(((2*(j.*w(j)))./0.002)+1))*((-(w(j).^2)./49)+(((2*(j.*w(j)))./7)+1))*((-(w(j).^2)./400000000)+(((2*(j.*w(j)))./20000)+1))*(((j.*w(j))./100)-1)); rr(j)=real(y(j)) ii(j)=imag(y(j)) xc(j)=cos(n(j)*w(j)*t)*rr(j) xs(j)=sin(n(j)*w(j)*t)*ii(j) ad(j)=xc(j)-xs(j) ri(j)=int(ad(j),w,1,2) end
Please help me and even let me know is my method of finding the integral of the function correct?

채택된 답변

Steven Lord
Steven Lord 2015년 8월 18일
Use INT to integrate an expression written using symbolic variables created using SYM or SYMS from Symbolic Math Toolbox.
Use INTEGRAL to integrate a function whose handle (which could be an anonymous function) you specify as the first input.
Use TRAPZ to integrate a function represented by a set of (X, Y) data.
  댓글 수: 1
ROSHAN SINGH
ROSHAN SINGH 2015년 8월 19일
Sir I am trying to evaluate the integral of the same function (Hr(w)*cos(n*w*t)-Hi(w)sin(n*w*t))dw. But this time I am trying to do it in conventional definite integral type.With limits from 0.0005 to 2000 Hz.I am running a loop using for command by varying the values of n? I am using the command int(y,w,0.0005,2000). But error comes wth a message explicit integral cannot be found? Please help me.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by