# XMAX must be a floating point scalar

4 views (last 30 days)
Pooyan Jafari on 5 Aug 2020
Commented: Walter Roberson on 5 Aug 2020
clc,clear all,close all;
syms beta theta r ;
D = 10;
C = 10;
L1 = 4;
Ri = D/2 + L1;
Rbeta0 = Ri;
Rt0 = (2*L1*cos(theta) + sqrt((D^2) - (2*(L1^2)) + (2*(L1^2)*cos(2*theta))) )/2;
Rmaxtb0 = (Rt0*Rbeta0)/Ri;
Rmaxtb00 = matlabFunction(Rmaxtb0)
Vmbeta0 = (2*(pi^2)*((D+(2*L1))^2)) / ((((2*L1*pi)+(pi*D))^2));
Vbeta0 = Vmbeta0 * (1 - ((r^2) / (Rmaxtb0^2))) * r;
Vbeta00 = matlabFunction(Vbeta0)
Wsigmat = integral2(Vbeta00,0,Rmaxtb00,0,2*pi,'AbsTol',1e-5, 'RelTol',1e-5)
I got the following error:
Error using integral2 (line 76)
XMAX must be a floating point scalar.
this is the integral:
any help?

Walter Roberson on 5 Aug 2020
For integral2(), the limits of the second variable can be function handles, but not the limits of the first variable.
You need to change the order of integration.
Vbeta00 = matlabFunction(Vbeta0)
You are letting matlabFunction pick the order of variables for integration. Are you sure that it is going to pick the "right" order? Are readers of your code going to be sure that it is going to pick the "right" order? You should be using the 'vars' option to specify the order of variables.... And when you do, you can switch the order of variables so that you can use the functions for the limits on r
Walter Roberson on 5 Aug 2020
Yes, that looks better.