Replace symsum/vpasum with numerical method
2 views (last 30 days)
Show older comments
Hi,
the following code is running, but relatively slow.
I therefore want to replace the symbolic calculation completely with a numeric one.
Tried to solve this with arrayfun, but didn't manage that either.
Maybe someone can give me a hint:
syms t m kappa N i
N = 500;
rb = 100;
ra = 90;
a = 20;
h = 10;
kappa = rb/ra;
u0 = 4*pi*10^-7;
t = a/ra;
m = a/rb;
[kappa,t] = meshgrid(1:0.05:3,0:0.05:0.95);
eq1 = 1./(2.*N.*log(kappa)).*vpasum(log((1+m.^2-2.*m.*cos(i.*2.*pi./N))./(1^2+t.^2-2.*t.*cos(i.*2.*pi./N))),i,0,N-1);
var = double((eq1).*100);
surf(t,kappa,var)
0 Comments
Accepted Answer
Walter Roberson
on 9 Dec 2021
%syms t m kappa N i
N = 500;
rb = 100;
ra = 90;
a = 20;
h = 10;
kappa = rb/ra;
u0 = 4*pi*10^-7;
t = a/ra;
m = a/rb;
[kappa,t] = meshgrid(1:0.05:3,0:0.05:0.95);
i = reshape(0:N-1,1,1,[]);
temp = log((1+m.^2-2.*m.*cos(i.*2.*pi./N))./(1^2+t.^2-2.*t.*cos(i.*2.*pi./N)));
eq1 = 1./(2.*N.*log(kappa)) .* sum(temp,3);
var = double((eq1).*100);
surf(t, kappa, var, 'edgecolor', 'none');
xlabel('t'); ylabel('\kappa');
More Answers (0)
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!