math - Numerical Integral in MatLab using integral command -
i trying compute value of integral using matlab
here other parameters have been defined or computed in earlier part of program follows
n = 2; sigma = [0.01 0.1]; l = [15]; meu = 4*pi*10^(-7); f = logspace ( 1, 6, 500); w=2*pi.*f; j = 1 : length(f) q2(j)= sqrt(sqrt(-1)*2*pi*f(j)*meu*sigma(2)); q1(j)= sqrt(sqrt(-1)*2*pi*f(j)*meu*sigma(1)); c2(j)= 1/(q2(j)); c1(j)= (q1(j)*c2(j) + tanh(q1(j)*l))/(q1(j)*(1+q1(j)*c2(j)*tanh(q1(j)*l))); z(j) = sqrt(-1)*2*pi*f(j)*c1(j); apprho(j) = meu*(1/(2*pi*f(j))*(abs(z(j))^2)); phi(j) = atan(imag(z(j))/real(z(j))); end %integration part c1=w./(2*pi); rho0=1; fun = @(x) log(apprho(x)/rho0)/(x.^2-w^2); c2= integral(fun,0,inf); phin=pi/4-c1.*c2;
i getting error
could , tell me going wrong.thanks in advance
define apprho
in separate *.m function file, instead of storing in array:
function [ result ] = apprho(x) % % calculate f , z based on input argument x % % ... % meu = 4*pi*10^(-7); result = meu*(1/(2*pi*f)*(abs(z)^2)); end
how calculate f , z you.
matlab's integral
works calling function (in case, apprho
) repeatedly @ many different x
values. x
values called integral
don't correspond 1: length(f)
values used in original code, why received errors.
Comments
Post a Comment