XMAX must be a floating point scalar

13 次查看(过去 30 天)
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)

采纳的回答

Walter Roberson
Walter Roberson 2020-8-5
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 个评论
Pooyan Jafari
Pooyan Jafari 2020-8-5
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)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by