XMIN must be a floating point scalar when xmin is from vpasolve

2 ビュー (過去 30 日間)
Ying li
Ying li 2019 年 5 月 22 日
コメント済み: Ying li 2019 年 5 月 22 日
I am trying to integrate the region between two surfaces. Their intersection can be solved numerically. Here is the code:
[solx,soly] = vpasolve([x.^2.*y.^2+x.^2+y.^2+2*x.*y-5 == 0, x.^2.*y+x+y==0],[x,y]) % find the left and right boundaries;
xmax=solx(3) % it turns out that the third entry is the right boundary I was looking for, which is 2.419...;
xmin=solx(4) % the four entry is the left boundary, which is -2.419...;
f = @(x,y) 5-x.^2-y.^2-x.*y-(x.^2.*y.^2+x.*y); % the function to be integrated;
ymax=@(x) (-2*x+sqrt(4*x.^2-4*(1+x.^2).*(x.^2-5)))./(2*(1+x.^2)); % upper boundary;
ymin=@(x) (-2*x-sqrt(4*x.^2-4*(1+x.^2).*(x.^2-5)))./(2*(1+x.^2)); % lower boundary;
I = integral2(f,xmin,xmax,ymin,ymax) % double integral;
This gives me the error message "XMIN must be a floating point scalar". I thought by indexing into solx, I already make xmax and xmin floating point scalars. In fact, in the 2nd and 3rd lines, the displays are
xmax =
xmin =
So why are they still not floating point scalars? And how to make them floating point scalars?
P.S. I tried to replace xmin by -2.42 and xmax by 2.42. It worked. I just want to understand why the above would not work.
Thank you!

採用された回答

madhan ravi
madhan ravi 2019 年 5 月 22 日
They are of symbolic type to convert them use double() :
xmax=double(solx(3));
xmin=double(solx(4));

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAssumptions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by