How to integrate a symbolic vector?

조회 수: 8 (최근 30일)
Bibigul
Bibigul 2017년 9월 5일
댓글: KSSV 2017년 9월 6일
If f=exp(t^2)*cos(t) then i can integrate 'f' using integral command (integral (f,0,1) ), but if 'F' is a vector (having elements similar to 'f' )then how can i integrate it? I am using same command but the answer is symbolic i.e still having 't'. I am not getting how to use trapz command. Your cooperation will be appreciated. Thanks in advance.
Kind Regards Bibigul

답변 (1개)

KSSV
KSSV 2017년 9월 6일
You should be having the values of t ..substitute those values in the integral expression using subs....convert the result into double using double and then call trapz .
  댓글 수: 2
Bibigul
Bibigul 2017년 9월 6일
@KSSV in my problem f=[exp(t^2)*cos(t)+9sin (t)+3exp(t^2), cos(t)-sin(t)*exp(t^2), exp(t^2)] and t=[0,1]. I have to solve int(f) from 0 to 1 and answer should be a vector. as per your advice i did the following f0=trapz(double(subs(f,t,0))); f1=trapz(double(subs(f,t,1))); now f0 and f1 are scalar. but in my problem solution must be a vector.
KSSV
KSSV 2017년 9월 6일
f{1} = @(t) exp(t.^2).*cos(t)+9*sin(t)+3.*exp(t.^2) ;
f{2} = @(t) cos(t)-sin(t).*exp(t.^2) ;
f{3} = @(t) exp(t.^2) ;
I = zeros(size(f)) ;
for i = 1:length(f)
I(i) = integral(f{i},0,1) ;
end
A = trapz(I) ;

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

카테고리

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