Hi, This is my Code
clc
clear all
syms Th
th1=5*pi/12 ;
th2=7*pi/12;
A11= @(Th) (10279222485063723*cos(Th).^2)/2684354560000 + (9*((7138348947960919*cos(Th).^2)/8589934592 + 1142135831673747/4294967296))/(625*cos(Th).^2)
A11Bar=integral(A11,th1,th2)
Acap =(10279222485063723*cos(Th).^2)/2684354560000 + (9*((7138348947960919*cos(Th).^2)/8589934592 + 1142135831673747/4294967296))/(625*cos(Th).^2)
Acap11 = @(Th) Acap
Acap11Bar=integral(Acap11,th1,th2)
I am trying to Integrate the Equation in A11 with limits th1 and th2. Using the Integral command, If I am using the equation directly it gives me the answer. But if Define the equation as Acap, Acap becomes symbolic and I dont get answer and the error comes as follows. My Question is , Th is a sym, but I get the answer for A11Bar, when using Th in A11, But why not the same in the other case.
A11 =
@(Th)(10279222485063723*cos(Th).^2)/2684354560000+(9*((7138348947960919*cos(Th).^2)/8589934592+1142135831673747/4294967296))/(625*cos(Th).^2)
A11Bar =
4.090565444758960e+04
Acap =
(2569805621265931*cos(Th)^2)/671088640000 + ((64245140531648271*cos(Th)^2)/8589934592 + 10279222485063723/4294967296)/(625*cos(Th)^2)
Acap11 =
@(Th)Acap
Error using integralCalc/finalInputChecks (line 511) Input function must return 'double' or 'single' values. Found 'sym'.
Error in integralCalc/iterateScalarValued (line 315) finalInputChecks(x,fx);
Error in integralCalc/vadapt (line 132) [q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75) [q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 88) Q = integralCalc(fun,a,b,opstruct);
Error in Untitled (line 13) Acap11Bar=integral(Acap11,th1,th2)

 Réponse acceptée

Torsten
Torsten le 27 Avr 2017
Use
Acap11 = matlabFunction(Acap)
Best wishes
Torsten.

5 commentaires

Hi Torsten, Thanks for your response, it did work, but there are few errors. Could you help on it as the answer varies.
A11 =
function_handle with value:
@(Th)(10279222485063723*cos(Th).^2)/2684354560000+(9*((7138348947960919*cos(Th).^2)/8589934592+1142135831673747/4294967296))/(625*cos(Th).^2)
A11Bar =
4.0906e+04
Acap =
(2569805621265931*cos(Th)^2)/671088640000 + ((64245140531648271*cos(Th)^2)/8589934592 + 10279222485063723/4294967296)/(625*cos(Th)^2)
Acap11 =
function_handle with value:
@(Th)cos(Th).^2.*3.829308779933946e3+1.0./cos(Th).^2.*(cos(Th).^2.*7.479118710808487e6+2.393317987458716e6).*(1.0./6.25e2)
Warning: Minimum step size reached near x = 1.5708. There may be a singularity, or the tolerances may be too tight for this problem. > In integralCalc/checkSpacing (line 456) In integralCalc/iterateScalarValued (line 319) In integralCalc/vadapt (line 132) In integralCalc (line 75) In integral (line 88) In Untitled (line 12)
Acap11Bar =
1.9726e+17
Torsten
Torsten le 27 Avr 2017
Modifié(e) : Torsten le 27 Avr 2017
cos(Th) = 0 at Th=pi/2, so you divide by 0.
Best wishes
Torsten.
Hi Torsten,
But if you check in my program given above, I have set the limits from 75 degrees to 105 degrees. I have not used 90 degrees ( pi/2 ) .
clc
clear all
syms Th
th1=5*pi/12 ;
th2=7*pi/12;
A11= @(Th) (10279222485063723*cos(Th).^2)/2684354560000 + (9*((7138348947960919*cos(Th).^2)/8589934592 + 1142135831673747/4294967296))/(625*cos(Th).^2)
A11Bar=integral(A11,th1,th2)
Acap =(10279222485063723*cos(Th).^2)/2684354560000 + (9*((7138348947960919*cos(Th).^2)/8589934592 + 1142135831673747/4294967296))/(625*cos(Th).^2) Acap11 = matlabFunction(Acap) Acap11BarA=integral(Acap11,th1,th2)
A11 =
function_handle with value:
@(Th)(10279222485063723*cos(Th).^2)/2684354560000+(9*((7138348947960919*cos(Th).^2)/8589934592+1142135831673747/4294967296))/(625*cos(Th).^2)
A11Bar =
4.6631e+04
Acap =
(2569805621265931*cos(Th)^2)/671088640000 + ((64245140531648271*cos(Th)^2)/8589934592 + 10279222485063723/4294967296)/(625*cos(Th)^2)
Acap11 =
function_handle with value:
@(Th)cos(Th).^2.*3.829308779933946e3+1.0./cos(Th).^2.*(cos(Th).^2.*7.479118710808487e6+2.393317987458716e6).*(1.0./6.25e2)
Warning: Minimum step size reached near x = 1.5708. There may be a singularity, or the tolerances may be too tight for this problem. > In integralCalc/checkSpacing (line 456) In integralCalc/iterateScalarValued (line 319) In integralCalc/vadapt (line 132) In integralCalc (line 75) In integral (line 88) In Untitled (line 12)
Acap11BarA =
1.1694e+18
Torsten
Torsten le 27 Avr 2017
Modifié(e) : Torsten le 27 Avr 2017
90° is in between 75° and 105°, and you integrate over the entire interval.
Note that x=1.5708 is approximately pi/2.
Best wishes
Torsten.
Hi, Thanks. I understood it now

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Design and Simulate SerDes Systems dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by