Issue with int() function
2 views (last 30 days)
Show older comments
Bathala Teja
on 15 Sep 2021
Commented: Bathala Teja
on 16 Sep 2021
I gave my script below. In that I am supposed to get Lrr in terms of theta but I am getting it in terms of values.
How is this possible??
syms theta phi
Nr = 20;
p = 2;
D = 1/(0.6*10^-3);
Q = 1/(40.27*10^-3);
theta_d = 1.1652;
theta_q = 0.4056;
Aog = (2/pi)*(D*theta_d+Q*theta_q);
k = 2;
Ginvi = 0;
for i=2:2:k
Akg = (4*(Q-D)/(pi*i))*(-1)^((i+4)/2)*sin(i*theta_q);
Ginvi = Ginvi+Akg*cos(p*i*(phi-theta));
end
Ginv = vpa((Ginvi+Aog), 4) % Ginv interms of phi and theta
w = 1;
a = (theta_d)/(Nr/p);
bd = a/2;
bq = ((theta_q)+a)/2;
nr = sym(zeros(1, Nr));
for j = 1:(2*p)
for n = (((j-1)*Nr/(2*p))+2):(j*(Nr/(2*p)))
for i = 1:w
Aord = (a+2*bd)/(2*pi);
Awr = (2/(a*pi*(i^2)))*(cos(i*bd)-cos(i*(a+bd)));
nr(1, n) = nr(1, n)+Awr*cos(i*(phi-theta-((n-j-1)*2*a)-((j-1)*(a+2*bq))));
end
nr(1, n) = Aord+nr(1, n);
end
end
for n = 1:(Nr/(2*p)):Nr
for i = 1:w
Aorq = (a+2*bq)/(2*pi);
Awr = (2/(a*pi*(i^2)))*(cos(i*bq)-cos(i*(a+bq)));
nr(1, n) = nr(1, n)+Awr*cos(i*(phi-theta-(((n-1)/(Nr/(2*p)))*theta_d)));
end
nr(1, n) = Aorq+nr(1, n);
end
NR = vpa(nr, 4) % row matrix interms of phi and theta
wr = sym(zeros(1, Nr));
for n = 1:Nr
wr(1, n) = (NR(1, n))-((1/(2*pi*Aog))*int((NR(1, n)*Ginv), phi, 0, 2*pi));
end
WR = vpa(wr, 4) % row matrix interms of theta
u = 1.2566*10^-(6);
r = 73.4*10^(-3);
l = 76*10^(-3);
lrr = sym(ones(Nr, Nr));
for i = 1:Nr
for j = 1:Nr
lrr(i, j) = (u*r*l)*int((NR(i)*WR(j)*Ginv), phi, 0, 2*pi);
end
end
Lrr = vpa(lrr, 4) % 20*20 matrix interms of theta
I am getting a result like this:
>> temp
Ginv =
757.9*cos(4.0*phi - 4.0*theta) + 1243.0
NR =
[0.1997*cos(phi - 1.0*theta) + 0.1016, 0.07397*cos(phi - 1.0*theta) + 0.03709, 0.07397*cos(theta - 1.0*phi + 0.233) + 0.03709, 0.07397*cos(theta - 1.0*phi + 0.4661) + 0.03709, 0.07397*cos(theta - 1.0*phi + 0.6991) + 0.03709, 0.1997*cos(theta - 1.0*phi + 1.165) + 0.1016, 0.07397*cos(theta - 1.0*phi + 1.571) + 0.03709, 0.07397*cos(theta - 1.0*phi + 1.804) + 0.03709, 0.07397*cos(theta - 1.0*phi + 2.037) + 0.03709, 0.07397*cos(theta - 1.0*phi + 2.27) + 0.03709, 0.1997*cos(theta - 1.0*phi + 2.33) + 0.1016, 0.07397*cos(theta - 1.0*phi + 3.142) + 0.03709, 0.07397*cos(theta - 1.0*phi + 3.375) + 0.03709, 0.07397*cos(theta - 1.0*phi + 3.608) + 0.03709, 0.07397*cos(theta - 1.0*phi + 3.841) + 0.03709, 0.1997*cos(theta - 1.0*phi + 3.496) + 0.1016, 0.07397*cos(theta - 1.0*phi + 4.712) + 0.03709, 0.07397*cos(theta - 1.0*phi + 4.945) + 0.03709, 0.07397*cos(theta - 1.0*phi + 5.178) + 0.03709, 0.07397*cos(theta - 1.0*phi + 5.412) + 0.03709]
WR =
[0.1997*cos(phi - 1.0*theta) - 9.247e-14, 0.07397*cos(phi - 1.0*theta) - 3.374e-14, 0.07397*cos(theta - 1.0*phi + 0.233) - 3.374e-14, 0.07397*cos(theta - 1.0*phi + 0.4661) - 3.374e-14, 0.07397*cos(theta - 1.0*phi + 0.6991) - 3.374e-14, 0.1997*cos(theta - 1.0*phi + 1.165) - 9.247e-14, 0.07397*cos(theta - 1.0*phi + 1.571) - 3.374e-14, 0.07397*cos(theta - 1.0*phi + 1.804) - 3.374e-14, 0.07397*cos(theta - 1.0*phi + 2.037) - 3.374e-14, 0.07397*cos(theta - 1.0*phi + 2.27) - 3.374e-14, 0.1997*cos(theta - 1.0*phi + 2.33) - 9.247e-14, 0.07397*cos(theta - 1.0*phi + 3.142) - 3.374e-14, 0.07397*cos(theta - 1.0*phi + 3.375) - 3.374e-14, 0.07397*cos(theta - 1.0*phi + 3.608) - 3.374e-14, 0.07397*cos(theta - 1.0*phi + 3.841) - 3.374e-14, 0.1997*cos(theta - 1.0*phi + 3.496) - 9.247e-14, 0.07397*cos(theta - 1.0*phi + 4.712) - 3.374e-14, 0.07397*cos(theta - 1.0*phi + 4.945) - 3.374e-14, 0.07397*cos(theta - 1.0*phi + 5.178) - 3.374e-14, 0.07397*cos(theta - 1.0*phi + 5.412) - 3.374e-14]
Lrr =
[ 1.092e-6, 4.043e-7, 3.934e-7, 3.612e-7, 3.095e-7, 4.308e-7, -1.485e-12, -9.338e-8, -1.817e-7, -2.602e-7, -7.518e-7, -4.043e-7, -3.934e-7, -3.612e-7, -3.095e-7, -1.024e-6, 4.456e-12, 9.338e-8, 1.817e-7, 2.602e-7]
[ 4.043e-7, 1.497e-7, 1.457e-7, 1.338e-7, 1.146e-7, 1.595e-7, -5.5e-13, -3.458e-8, -6.729e-8, -9.636e-8, -2.784e-7, -1.497e-7, -1.457e-7, -1.338e-7, -1.146e-7, -3.793e-7, 1.65e-12, 3.458e-8, 6.729e-8, 9.637e-8]
[ 3.934e-7, 1.457e-7, 1.497e-7, 1.457e-7, 1.338e-7, 2.41e-7, 3.458e-8, -5.5e-13, -3.458e-8, -6.729e-8, -2.032e-7, -1.457e-7, -1.497e-7, -1.457e-7, -1.338e-7, -4.014e-7, -3.458e-8, 1.65e-12, 3.458e-8, 6.729e-8]
[ 3.612e-7, 1.338e-7, 1.457e-7, 1.497e-7, 1.457e-7, 3.095e-7, 6.729e-8, 3.458e-8, -5.5e-13, -3.458e-8, -1.17e-7, -1.338e-7, -1.457e-7, -1.497e-7, -1.457e-7, -4.018e-7, -6.729e-8, -3.458e-8, 1.65e-12, 3.458e-8]
[ 3.095e-7, 1.146e-7, 1.338e-7, 1.457e-7, 1.497e-7, 3.612e-7, 9.636e-8, 6.729e-8, 3.458e-8, -5.5e-13, -2.444e-8, -1.146e-7, -1.338e-7, -1.457e-7, -1.497e-7, -3.805e-7, -9.636e-8, -6.729e-8, -3.458e-8, 1.65e-12]
[ 4.308e-7, 1.595e-7, 2.41e-7, 3.095e-7, 3.612e-7, 1.092e-6, 3.715e-7, 3.246e-7, 2.602e-7, 1.817e-7, 4.308e-7, -1.595e-7, -2.41e-7, -3.095e-7, -3.612e-7, -7.518e-7, -3.715e-7, -3.246e-7, -2.602e-7, -1.817e-7]
[-1.485e-12, -5.5e-13, 3.458e-8, 6.729e-8, 9.636e-8, 3.715e-7, 1.497e-7, 1.457e-7, 1.338e-7, 1.146e-7, 2.932e-7, -5.5e-13, -3.458e-8, -6.729e-8, -9.636e-8, -1.402e-7, -1.497e-7, -1.457e-7, -1.338e-7, -1.146e-7]
[ -9.338e-8, -3.458e-8, -5.5e-13, 3.458e-8, 6.729e-8, 3.246e-7, 1.457e-7, 1.497e-7, 1.457e-7, 1.338e-7, 3.496e-7, 3.458e-8, -5.5e-13, -3.458e-8, -6.729e-8, -4.879e-8, -1.457e-7, -1.497e-7, -1.457e-7, -1.338e-7]
[ -1.817e-7, -6.729e-8, -3.458e-8, -5.5e-13, 3.458e-8, 2.602e-7, 1.338e-7, 1.457e-7, 1.497e-7, 1.457e-7, 3.87e-7, 6.729e-8, 3.458e-8, -5.5e-13, -3.458e-8, 4.522e-8, -1.338e-7, -1.457e-7, -1.497e-7, -1.457e-7]
[ -2.602e-7, -9.636e-8, -6.729e-8, -3.458e-8, -5.5e-13, 1.817e-7, 1.146e-7, 1.338e-7, 1.457e-7, 1.497e-7, 4.036e-7, 9.636e-8, 6.729e-8, 3.458e-8, -5.5e-13, 1.368e-7, -1.146e-7, -1.338e-7, -1.457e-7, -1.497e-7]
[ -7.518e-7, -2.784e-7, -2.032e-7, -1.17e-7, -2.444e-8, 4.308e-7, 2.932e-7, 3.496e-7, 3.87e-7, 4.036e-7, 1.092e-6, 2.784e-7, 2.032e-7, 1.17e-7, 2.444e-8, 4.308e-7, -2.932e-7, -3.496e-7, -3.87e-7, -4.036e-7]
[ -4.043e-7, -1.497e-7, -1.457e-7, -1.338e-7, -1.146e-7, -1.595e-7, -5.5e-13, 3.458e-8, 6.729e-8, 9.636e-8, 2.784e-7, 1.497e-7, 1.457e-7, 1.338e-7, 1.146e-7, 3.793e-7, -5.5e-13, -3.458e-8, -6.729e-8, -9.636e-8]
[ -3.934e-7, -1.457e-7, -1.497e-7, -1.457e-7, -1.338e-7, -2.41e-7, -3.458e-8, -5.5e-13, 3.458e-8, 6.729e-8, 2.032e-7, 1.457e-7, 1.497e-7, 1.457e-7, 1.338e-7, 4.014e-7, 3.458e-8, -5.5e-13, -3.458e-8, -6.729e-8]
[ -3.612e-7, -1.338e-7, -1.457e-7, -1.497e-7, -1.457e-7, -3.095e-7, -6.729e-8, -3.458e-8, -5.5e-13, 3.458e-8, 1.17e-7, 1.338e-7, 1.457e-7, 1.497e-7, 1.457e-7, 4.018e-7, 6.729e-8, 3.458e-8, -5.5e-13, -3.458e-8]
[ -3.095e-7, -1.146e-7, -1.338e-7, -1.457e-7, -1.497e-7, -3.612e-7, -9.636e-8, -6.729e-8, -3.458e-8, -5.5e-13, 2.444e-8, 1.146e-7, 1.338e-7, 1.457e-7, 1.497e-7, 3.805e-7, 9.636e-8, 6.729e-8, 3.458e-8, -5.5e-13]
[ -1.024e-6, -3.793e-7, -4.014e-7, -4.018e-7, -3.805e-7, -7.518e-7, -1.402e-7, -4.879e-8, 4.522e-8, 1.368e-7, 4.308e-7, 3.793e-7, 4.014e-7, 4.018e-7, 3.805e-7, 1.092e-6, 1.402e-7, 4.879e-8, -4.522e-8, -1.368e-7]
[ 4.456e-12, 1.65e-12, -3.458e-8, -6.729e-8, -9.636e-8, -3.715e-7, -1.497e-7, -1.457e-7, -1.338e-7, -1.146e-7, -2.932e-7, -5.5e-13, 3.458e-8, 6.729e-8, 9.636e-8, 1.402e-7, 1.497e-7, 1.457e-7, 1.338e-7, 1.146e-7]
[ 9.338e-8, 3.458e-8, 1.65e-12, -3.458e-8, -6.729e-8, -3.246e-7, -1.457e-7, -1.497e-7, -1.457e-7, -1.338e-7, -3.496e-7, -3.458e-8, -5.5e-13, 3.458e-8, 6.729e-8, 4.879e-8, 1.457e-7, 1.497e-7, 1.457e-7, 1.338e-7]
[ 1.817e-7, 6.729e-8, 3.458e-8, 1.65e-12, -3.458e-8, -2.602e-7, -1.338e-7, -1.457e-7, -1.497e-7, -1.457e-7, -3.87e-7, -6.729e-8, -3.458e-8, -5.5e-13, 3.458e-8, -4.522e-8, 1.338e-7, 1.457e-7, 1.497e-7, 1.457e-7]
[ 2.602e-7, 9.637e-8, 6.729e-8, 3.458e-8, 1.65e-12, -1.817e-7, -1.146e-7, -1.338e-7, -1.457e-7, -1.497e-7, -4.036e-7, -9.636e-8, -6.729e-8, -3.458e-8, -5.5e-13, -1.368e-7, 1.146e-7, 1.338e-7, 1.457e-7, 1.497e-7]
>>
Actually I have to get Lrr in terms of theta. Instead I am getting in some values.
Can anyone tell me what is the issue??
0 Comments
Accepted Answer
Walter Roberson
on 15 Sep 2021
The int() work out independent of theta.
cos() integrated over 0 to 2*pi is sin(2*pi)-sin(0) which is 0.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!