XMAX must be a floating point scalar

16 Ansichten (letzte 30 Tage)
Pooyan Jafari
Pooyan Jafari am 5 Aug. 2020
Kommentiert: Walter Roberson am 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?
(thanks in advance)

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 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 Kommentare
Pooyan Jafari
Pooyan Jafari am 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)
Walter Roberson
Walter Roberson am 5 Aug. 2020
Yes, that looks better.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Simulink Coder finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by