필터 지우기
필터 지우기

integral (numerical integration) base on r

조회 수: 2 (최근 30일)
shahin hashemi
shahin hashemi 2020년 10월 4일
답변: Walter Roberson 2020년 10월 4일
dear all
i want to use integral (numerical integration) base on r
for W for the code below :
clc
clear all
m=9;
a=1;
u=[3.8317 7.0156 10.1735 13.3237 16.4706 19.6159 22.7601 25.9037 29.0468 ];
syms r
YY1 = zeros(1,m,'sym');
for j=1:m
yy1 = zeros(1,100,'sym');
yy0 = zeros(1,100,'sym');
for i=1:100
yy0(i)=(((-1)^(i-1))*((((u(j))/a)*r)^(2*(i-1))))/((2^(2*(i-1)))*((factorial(i-1))^2)) ;
yy1(i)=(((-1)^(i-1))/((factorial(i-1))*(factorial(i))))*(((u(j))*r)/2)^(2*(i-1)+1) ;
end
YY1(j)=sum(yy1);
YY0(j)=sum(yy0);
W(j)=((YY1(j)/r)*YY0(j));
end
as it is obvious i have m=9 W that is base on r for diffrent u
i want to use numerical integration base on r in interval of 0 to 1
as i read matlab help for useing integral i should make function but i dont know to make function
i really appreciate if u could help me

답변 (1개)

Walter Roberson
Walter Roberson 2020년 10월 4일
a = 1;
u = [3.8317 7.0156 10.1735 13.3237 16.4706 19.6159 22.7601 25.9037 29.0468 ];
m = length(u);
i = (1 : 100) .';
u = reshape(u, 1, 1, []);
Wfun = @(r) sum((((-1).^(i-1))./((factorial(i-1)).*(factorial(i)))).*(((u).*r)/2).^(2*(i-1)+1)) ./r .* ...
sum((((-1).^(i-1)).*((((u)/a).*r).^(2*(i-1))))./((2.^(2*(i-1))).*((factorial(i-1)).^2))) ;
W = squeeze( integral(Wfun, 0, 1, 'arrayvalued', true));
The output will be a vector the same length as u is.

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by