Why am i getting the same error while plotting a function?

1 view (last 30 days)
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]);
Sarbhanu Saha
Sarbhanu Saha on 26 Aug 2021
Sorry but i don't understand what you mean to say. In the question, i did give the whole formula. But if you want the actual formula in one part, then the below one is that.
z = exp(a*r)*((r-ri)^2)*((r-ro)^2)*cos(n*(tan(b)*log(ri/r) + phi))/(r^m);
Mkrit = (pi*vpaintegral(vpaintegral((D*((diff(z,r,2) + (1/r)*diff(z,r) + (1/r^2)*diff(z,phi,2))^2 + 2*(1-u)*(((1/r)*diff(diff(z,r),phi) - (1/r^2)*diff(z,phi))^2 - diff(z,r,2)*((1/r)*diff(z,r) + (1/r^2)*diff(z,phi,2)))))*r,r,[ri ro]),phi,[0 2*pi]))/((-1)*vpaintegral(vpaintegral(((1/r^3)*diff(z,r)*diff(z,phi))*r,r,[ri ro]),phi,[0 2*pi]));
q = abs(Mkrit);

Sign in to comment.

Answers (1)

G A on 26 Aug 2021
Edited: G A on 26 Aug 2021
doc vpaintegral
vpaintegral(f,a,b) numerically approximates f from a to b.
vpaintegral(f,[a b]) is equal to vpaintegral(f,a,b).
vpaintegral(f,x,a,b) performs numerical integration using the integration variable x.
in all cases a and b are scalars or return scalars if they are symbolic functions or expressions
ri = linspace(5, 15, 100); is a vector


Find more on Data Type Identification 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!