FSOLVE requires all values returned by functions to be of data type double. showing while solving an algebraic equation in matlab ??

1 次查看(过去 30 天)
I want to solve the eqs for u_s and find out the value of u_s but i am getting error while solving the equation using fsolve. Can you provide some solution for this problem ?? Thank you
type untitled03.m
clc clear close all a = deg2rad(45); m = 0.683; We = 277; Re = 75; b = (-0.13*m.^3+0.263*m.^2 +0.039*m +0.330)/tan(a); s_b = 0.0042; p = pi/2; R = 1.7440; t = deg2rad(0); syms q x = b*cos(t)*sin(a)^2; x01 = 4*((1-cos(t)^2*cos(a)^2)); x02 = (b*sin(t)*sin(a))^2; q_j = -((x -(x01-x02)^0.5)/(x01/4)); d = (b^2*sin(a)^2 + q^2*(1-cos(t)^2*cos(a)^2) + 2*b*q*cos(t)*sin(a)^2)^0.5; u_j = 2*(m-1)*(4*d^2-1) + m; F = int(q*u_j, q, 0, q_j); G = int(q*u_j^3,q,0,q_j); eqs = @(u_s)((4*sin(a).^3*F.^4*(R-q_j)*(R.^5-q_j.^5))/(15*q_j.^7*R.^5*Re))+... ((((R.^3-q_j.^3)*F.^3*sin(a).^3)/(9*q_j.^3*R.^3))-((R-q_j)*F*((4/q_j)+sin(a))))*u_s+... (R-q_j)*F*sin(a)*u_s.^3+... (R.^2 +2*R*sqrt(pi*s_b))+(16*F.^3*sin(a)*(R-q_j).^2)/(3*q_j.^3*R*Re)*u_s^2; sol = fsolve(eqs,0.5);

采纳的回答

Walter Roberson
Walter Roberson 2023-12-8
F and G are int() calls. Even if they evaluate to closed forms that were rational numbers, they have symbolic results. When you create an anonymous function that includes F and G, any numeric coefficients will be converted to symbolic at the point F or G is encountered, so the anonymous function will return something of data type sym even in the best possible case. But fsolve requires single or double. fsolve refuses to even try to convert sym to double.
Instead of constructing that anonymous function you should use matlabFunction()
  7 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Number Theory 的更多信息

标签

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by