integral (numerical integration) base on r
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (1)
Walter Roberson
le 4 Oct 2020
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.
0 commentaires
Voir également
Catégories
En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!