MATLAB Answers

XMAX must be a floating point scalar

18 views (last 30 days)
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?
(thanks in advance)

  0 Comments

Sign in to comment.

Accepted Answer

Walter Roberson
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

  3 Comments

Pooyan Jafari
Pooyan Jafari on 5 Aug 2020
thank you
but I can't change the order of integration and the limits of the first variable have to be Rmaxtb00 which is function handles!!
can you modify it somehow to get the correct result (wsigmat=78.5398)? I tried but I couldn't..
I also used 'vars' options but it didn't work.
Pooyan Jafari
Pooyan Jafari on 5 Aug 2020
I tried this one and it is working!
am I doing right based on what you said?
Thanka alot for your kind help
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,'Vars',[theta r])
Wsigmat = integral2(Vbeta00,0,2*pi,0,Rmaxtb00,'AbsTol',1e-5, 'RelTol',1e-5)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!