Why the below mentioned function plotting is unsuccessful?
13 views (last 30 days)
Show older comments
I want to create a plot for the below given function. But, I always get the same error. The code for the plotting is:
syms a m n b r s phi E D ri ro u;
ro = 80;
E = 210000;
s = 1;
u = 3./10;
D = (E.*s.^3)./(12.*(1-u.^2));
a = 0.005;
m = 1.1492;
n = 2;
b = 0.6158;
Pi = sym(pi);
assume(r >= ri);
assume(r <= ro);
ri = linspace(5, 15, 100);
z = exp(a.*r).*((r-ri).^2).*((r-ro).^2).*cos(n.*(tan(b).*log(ri./r) + phi))./(r.^m);
dzr = diff(z,r);
dzrr = diff(dzr,r);
dzp = diff(z,phi);
dzpp = diff(dzp,phi);
dzrp = diff(dzr,phi);
q2inside = ((1./r.^3).*dzr.*dzp).*r;
q2inint = vpaintegral(q2inside,phi,[0 2.*Pi]);
q2 = (-1).*vpaintegral(q2inint,r,[ri ro]);
q1inside = (D.*((dzrr + (1./r).*dzr + (1./r.^2).*dzpp).^2 + 2.*(1-u).*(((1./r).*dzrp - (1./r.^2).*dzp).^2 - dzrr.*((1./r).*dzr + (1./r.^2).*dzpp)))).*r;
q1inint = vpaintegral(q1inside,r,[ri ro]);
q1 = Pi.*vpaintegral(q1inint,phi,[0, 2.*Pi]);
Mkrit = q1./q2;
q = double(abs(Mkrit));
plot(ri, q)
The error that i am encountering is :
Operands to the logical and (&&) and or (||) operators must be convertible to logical scalar values.
Error in sym/vpaintegral (line 182)
(isinf(b) && isempty(symvar(b)) && ~isreal(b))
Error in Graph_Try (line 23)
q2 = (-1).*vpaintegral(q2inint,r,[ri ro]);
0 Comments
Answers (1)
Walter Roberson
on 17 Aug 2021
Your ri is a vector. You cannot use a vector as one of the bounds for vpaintegral, with the exception that you can supply a vector of two elements as the bounds instead of separate upper and lower boundaries.
Your expression to be integrated is a vector. Are you wanting to integrate each element of the vector with respect to each different lower bound, or are you wanting to integrate each one with respect to only its corresponding lower bound? Remember that you can arrayfun() calls to vpaintegral
4 Comments
Walter Roberson
on 28 Aug 2021
syms a m n b r s phi E D ri ro u x;
ro = 80;
E = 70000;
s = 1;
u = 3./10;
D = (E.*s.^3)./(12.*(1-u.^2));
a = 0.005;
m = 1.1492;
n = 2;
b = 0.6158;
Pi = sym(pi);
assume(r >= ri);
assume(r <= ro);
xvals = 5:0.5:15;
numx = length(xvals)
for xidx = 1 : numx
x = xvals(xidx);
ri = x;
z = exp(a.*r).*((r-ri).^2).*((r-ro).^2).*cos(n.*(tan(b).*log(ri./r) + phi))./(r.^m);
dzr = diff(z,r);
dzrr = diff(dzr,r);
dzp = diff(z,phi);
dzpp = diff(dzp,phi);
dzrp = diff(dzr,phi);
q2inside = ((1./r.^3).*dzr.*dzp).*r;
q2inint = vpaintegral(q2inside,phi,[0 2.*Pi]);
q1inside = (D.*((dzrr + (1./r).*dzr + (1./r.^2).*dzpp).^2 + 2.*(1-u).*(((1./r).*dzrp - (1./r.^2).*dzp).^2 - dzrr.*((1./r).*dzr + (1./r.^2).*dzpp)))).*r;
q1inint = vpaintegral(q1inside,phi,[0 2.*Pi]);
q2 = (-1).*vpaintegral(q2inint,r,[ri ro]);
q1 = Pi.*vpaintegral(q1inint,r,[ri ro]);
Mkrit = q1./q2;
q(xidx) = double(abs(Mkrit));
end
plot(xvals, q)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!