Problem with vpa integral
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Aviral Srivastava
am 15 Mär. 2024
Kommentiert: Walter Roberson
am 15 Mär. 2024
Vu(k,T) = ((gama_q.*(g2).*(T^2)))./(2*k);
Vii_u(k,T) = diff(Vu ,k );
rho_u(k,T) = (-Vii_u).*(Vu^2)*l1;
%Fi_u = matlabFunction(rho_u.*l1);
Fii( 1 ) = vpaintegral(rho_u, k_min_q ,4*k_min_q);
P.S. I am using vpaintegral becasue int does not yield a functional expression and fails to calculate integral. I tried numerical approach but the error is above the bounds. Once I get Fii as a function of T then I need to differenciate Fii w.r.t T.
k and T are sym variables;
g2 is another sym expression of the following form
g2(k) = N./log(1 + ((k.^2)./lambda^2));
I want Fii(1) to be an integrak done w.r.t k so that the resultant expression is a function of only T.
I am getting the follwing error:
The following error occurred converting from symfun to double:
Unable to convert expression into double array.
Error in m_t_u_B2_transition (line 61)
Fii( 1 ) = vpaintegral(rho_u, k_min_q ,4*k_min_q);
0 Kommentare
Akzeptierte Antwort
Steven Lord
am 15 Mär. 2024
This type of error indicates you're assiging a symbolic expression into an element of a double array. When you do this, MATLAB will attempt to convert the symbolic expression into double so it "fits" in the double array. Sometimes this works.
sqrt2 = sqrt(sym(2))
doubleArray = zeros(1, 5)
doubleArray(2) = sqrt2
Sometimes MATLAB cannot perform that conversion.
syms x
symArray = zeros(1, 5, 'sym')
symArray(2) = sqrt2
symArray(4) = x^2
doubleArray(4) = x^2
Two potential ways to resolve this error could be to substitute numeric values into the symbolic expression, so instead of a value like "x^2" it has a numeric value (if I substituted x = 3 into the symbolic expression x^2, MATLAB would store the value 9 in doubleArray(4)) or to define the array as symbolic at the start rather than double (like I did with symArray above.)
5 Kommentare
Torsten
am 15 Mär. 2024
We might be able to help if you supply executable code that reproduces the error message you get. The code from above is incomplete because sym declarations and/or parameters are missing.
Walter Roberson
am 15 Mär. 2024
Fii( 1 ) = vpaintegral(rho_u, k_min_q ,4*k_min_q);
You must have previously assigned Fii as a numeric array. You need to insert
Fii = sym(Fii);
before the above statement to fix this problem.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Conversion Between Symbolic and Numeric finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!